This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
ll n,q;
cin >> n >> q;
vector<pair<ll , ll>> v;
stack<ll> s;
ll p[n];
for (ll i=0; n>i; i++)
{
p[i] = 0;
}
ll sum[n];
for (ll i=0; n>i; i++)
{
ll a,b;
cin >> a >> b;
v.push_back({a , b});
sum[i] = v[i].second;
if (i > 0) sum[i] += sum[i-1];
}
while (q--)
{
ll a,b;
cin >> a >> b;
a--;
for (ll i=0; n>i; i++)
{
if (a == 0 && sum[i] >= b)
{
cout << i + 1 << endl;
a = -3;
break;
}
if (a > 0 && sum[i] - sum[a - 1] >= b)
{
cout << i + 1 << endl;
a = -3;
break;
}
}
if (a != -3)
{
cout << 0 << endl;
}
}
return 0;
}
Compilation message (stderr)
fountain.cpp: In function 'int main()':
fountain.cpp:13:5: warning: variable 'p' set but not used [-Wunused-but-set-variable]
13 | ll p[n];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |