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>
using namespace std;
int main(){
int n,q;
cin>>n>>q;
int d[n+1],c[n+1],r[q],v[q];
d[0]=0;
c[0]=0;
for(int i=1;i<=n;i++){
cin>>d[i]>>c[i];
}
int p;
for(int i=0;i<q;i++){
cin>>r[i]>>v[i];
p=0;
for(int j=r[i];j<=n;j++){
if(d[j]>p){
v[i]-=c[j];
p=d[j];
}
if(v[i]<=0) {
cout<<j<<endl;
break;
}
if(j==n){
cout<<0<<endl;
break;
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |