#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vl vector<ll>
#define endl "\n"
#define INF 0x3F3F3F3F
using namespace std;
int main(){
ll n,q,r,x,i;
cin>>n>>q;
vl d(n+1),c(n+1),pre(n+2);
pre[0]=0;
pre[n+1]=INF;
for(i=1;i<=n;i++){
cin>>d[i]>>c[i];
pre[i]=pre[i-1]+c[i];
}
for(i=0;i<=n+1;i++){
cout<<pre[i]<<' ';
}
cout<<endl;
while(q--){
cin>>r>>x;
ll nw=x+pre[r-1];
ll idx=upper_bound(pre.begin(),pre.end(),nw)-pre.begin();
if(pre[idx-1]==nw){
cout<<idx-1<<endl;
}
else if(idx==(n+1)){
cout<<0<<endl;
}
else{
cout<<idx<<endl;
}
}
}
/*
5 10
3 5
5 7
7 9
9 11
11 13
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
296 ms |
5268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |