Submission #448047

#TimeUsernameProblemLanguageResultExecution timeMemory
448047fuad27Fountain (eJOI20_fountain)C++14
0 / 100
1580 ms2380 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #pragma GCC optimize("Ofast") int32_t main () { int n, q; cin >> n >> q; vector<int> d; vector<int> c; for(int i = 0;i<n;i++) { int a, b; cin >> a >> b; d.push_back(a); c.push_back(b); } while(q--) { int i, v; cin >> i >> v; i--; int prev = i; while(v > 0 and i < n) { if(prev == i)v-=c[i]; else if(d[i] >= d[prev]) { v-=c[i]; prev = i; } i++; } if(v > 0)cout<<0<<endl; else cout<<i<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...