#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;
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 |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Correct |
6 ms |
340 KB |
Output is correct |
7 |
Correct |
4 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1583 ms |
2184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Correct |
6 ms |
340 KB |
Output is correct |
7 |
Correct |
4 ms |
348 KB |
Output is correct |
8 |
Execution timed out |
1583 ms |
2184 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |