Submission #576488

#TimeUsernameProblemLanguageResultExecution timeMemory
576488ammar124Fountain (eJOI20_fountain)C++14
30 / 100
1585 ms2028 KiB
#include <bits/stdc++.h> #define endl '\n' #define ll long long using namespace std; int const maxin = 1e5+6; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int a,q; cin>>a>>q; pair<ll , ll> arr[a]; for(int i=1;i<a+1;i++) { cin>>arr[i].first>>arr[i].second; } while(q--) { ll x,y; cin>>x>>y; ll last = arr[x].first; y-=arr[x].second; if(y <= 0) cout<<x<<endl; else { for(int i=x+1;i<a+1;i++) { if(arr[i].first > last) { last = arr[i].first; y-=arr[i].second; } if(y <= 0) { cout<<i<<endl; break; } } if(y > 0) cout<<0<<endl; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...