# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
576463 | MrM7md | Fountain (eJOI20_fountain) | C++17 | 1574 ms | 2316 KiB |
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;
#define int long long
#define endl "\n"
const int MOD = 1e9 + 7;
pair<int,int> a[100000];
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,q;
cin >> n>>q;
for(int i=0;i<n;i++){
cin >> a[i].first>>a[i].second;
}
a[n]={INT_MAX,INT_MAX};
while(q--){
int r,v;
cin >>r >> v;
int cur=a[r-1].first;
int ans;
for(int i=r-1;i<=n;i++){
if(a[i].first>=cur){
cur=a[i].first;
v-=a[i].second;
if(v<=0) {
ans=i;
break;
}
}
}
if(ans==n)ans=-1;
cout<<ans+1<<endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |