Submission #389836

#TimeUsernameProblemLanguageResultExecution timeMemory
389836AlmaFountain (eJOI20_fountain)C++14
30 / 100
82 ms4492 KiB
#include <bits/stdc++.h> using namespace std; int f (int p, int n, vector<int> & s, int l) { int x = s[p-1]; int lo = p, mid, hi = n, res = 0; while (lo <= hi) { mid = lo + (hi-lo) / 2; if (s[mid] - x - l >= 0) { hi = mid-1; res = mid; } else { lo = mid+1; } } return res; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, q, a, b, p, l, sum = 0; cin >> n >> q; vector<int> s(n+1); s[0] = 0; for (int i = 1; i <= n; i++) { cin >> a >> b; sum += b; s[i] = sum; } while (q--) { cin >> p >> l; cout << f(p, n, s, l) << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...