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 <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, q, r, v;
cin >> n >> q;
vector<pair<int,int>> vii (n); // {diameter, capacity}
for (int i = 0; i < n; i++)
cin >> vii[i].first >> vii[i].second;
sort(vii.begin(), vii.end());
while (q--) {
cin >> r >> v;
for (int i = r-1; i < n; i++) {
v -= vii[i].second;
if (v > 0 && i == n-1) {
cout << 0 << '\n';
} else if (v <= 0) {
cout << i+1 << '\n';
break;
} else {
continue;
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |