#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
int main () {
int n, q;
cin >> n >> q;
vector<int> d;
vector<int> c;
for(int i = 0;i<n;i++) {
int a, b;
cin >> a >> b;
d.push_back(a);
c.push_back(b);
}
while(q--) {
int i, v;
cin >> i >> v;
i--;
int prev = i;
while(v > 0 and i < n) {
if(prev == i)v-=c[i];
else if(d[i] >= d[prev]) {
v-=c[i];
prev = i;
}
i++;
}
if(v > 0)cout<<0<<endl;
else cout<<i<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1594 ms |
2916 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |