#include<iostream>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,q;
cin>>n>>q;
int d[n+1],c[n+1],r[q],v[q];
d[0]=0;
c[0]=0;
int pr[n];
pr[0]=0;
for(int i=1;i<=n;i++){
cin>>d[i]>>c[i];
pr[i]=pr[i-1]+c[i];
}
for(int i=0;i<q;i++){
cin>>r[i]>>v[i];
int l = r[i];
int r1 = n;
while(l<=r1){
int mid = (l+r1)/2;
if(pr[mid]-pr[r[i]]>v[i]){
r1 = mid;
if(pr[mid-1]-pr[r[i]]<v[i]){
cout<<mid-1<<endl;
break;
}
}
else{
l = mid;
if(pr[mid+1]-pr[r[i]]>v[i]){
cout<<mid<<endl;
break;
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
198 ms |
3928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |