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 <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
const int MXN = 1e5 + 10 ;
int cap[MXN] = {0};
int di[MXN] = {0};
int pscap[MXN] = {0};
int main(){
//faster io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//subtask 2
int N, Q;
cin>>N>>Q;
for(int i=1; i<=N; i++) cin>>di[i]>>cap[i];
for(int i=1; i<=N; i++) pscap[i] = pscap[i-1] + cap[i];
while(Q--){
int R, V;
cin>>R>>V;
int idx = lower_bound(pscap + R, pscap + N + 1, (V + pscap[R-1])) - (pscap);
if(idx>N) cout<<"0\n";
else cout<<idx<<"\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... |