#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstring>
#include <set>
#include <cmath>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, q; cin >> n >> q;
int diameters[n];
int capacities[n];
for (int i = 0; i < n; i++) cin >> diameters[i] >> capacities[i];
for (int i = 1; i < n; i++) diameters[i] += diameters[i - 1];
for (int iq = 0; iq < q; iq++) {
int r, v; cin >> r >> v; r--;
if (r > 0) v += diameters[r - 1];
if (v > diameters[n - 1]) {
cout << 0 << endl;
continue;
}
cout << lower_bound(diameters, diameters + n, v) - diameters + 1 << endl;
}
}
# |
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 |
158 ms |
1692 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 |
- |