#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";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
4836 KB |
Output is correct |
2 |
Correct |
47 ms |
4948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |