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;
typedef long long ll;
int main(){
int n, q; cin >> n >> q;
int questions[n][2]; // n[0] = rating, n[1] = imple
for(int i = 0 ; i < n ; i++) cin >> questions[i][0] >> questions[i][1];
int ans[q];
for(int i = 0 ;i < q ; i++){
int analysis = 0;
int awal, imple; cin >> awal >> imple;
for(int j = awal - 1 ; j < n ; j++){
if(analysis < questions[j][0]){
imple -= questions[j][1];
analysis = questions[j][0];
if(imple <= 0){
ans[i] = j + 1;
break;
}
}
}
if(imple > 0) ans[i] = 0;
}
for(int i = 0 ; i < q ; i++) cout << ans[i] << endl;
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... |