#include <vector>
#include <algorithm>
using namespace std;
#include <iostream>
vector<int> pre;
int n;
/*int lower_bo(int l, int r, int val) {
int mid = (l + r) / 2;
if (pre[mid] < val && (mid == n || pre[mid+1] >= val) ) {
return mid+1;
}
if (pre[mid] < val) {
return lower_bo(mid + 1, r, val);
}
if (pre[mid] > val) {
return lower_bo(l, mid - 1, val);
}
}*/
int main()
{
int q;
cin >> n >> q;
vector<int> d;
vector<int> c;
pre.push_back(0);
for (int i = 1; i < n+1; i++) {
int x, y;
cin >> x >> y;
d.push_back(x);
pre.push_back(y+pre[i-1]);
c.push_back(y);
}
for (int i = 0; i < q; i++) {
int r, v;
cin >> r >> v;
int it = r;
while (v > c[r]) {
if (r == n) {
it = 0;
break;
}
r++;
v -= c[r];
}
//int it = lower_bo(1, n, v + pre[r - 1]);
cout << it << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1586 ms |
1788 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |