Submission #657298

#TimeUsernameProblemLanguageResultExecution timeMemory
657298BananFountain (eJOI20_fountain)C++17
30 / 100
1586 ms3940 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define double long double #define endl '\n' #define sz(a) (int)a.size() #define pb push_back #define fs first #define sc second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() int const INF = LONG_LONG_MAX; int n, q, d[200005], c[200005]; void solve() { cin>>n>>q; for(int i=1;i<=n;i++) { cin>>d[i]>>c[i]; } d[n+1]=INF; c[n+1]=INF; while(q--) { int r, v; cin>>r>>v; bool b=1; while(v-c[r]>0) { v-=c[r]; int k=1; while(d[r]>=d[r+k]) { k++; } r+=k; if(r>n){b=0;break;} } if(b){cout<<r<<endl;}else{cout<<0<<endl;} } } int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int tc=1; //cin>>tc; while(tc--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...