# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
337627 | 2020-12-21T09:46:04 Z | kutbilim_one | Divide and conquer (IZhO14_divide) | C++14 | 1 ms | 492 KB |
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define all(x) x.begin(),x.end() #define int long long const int MAXN = 100100; int x[MAXN], g[MAXN], d[MAXN], n; int prg[MAXN], prd[MAXN], mn[MAXN]; int ans; int search(int i, int E){ int l = 1, r = i, pos = 1; while(l < r){ int m = (l+r)<<1; if(mn[m] <= E) r = m; else l = m+1; } return r; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for(int i = 1; i <= n; i++) cin >> x[i] >> g[i] >> d[i]; mn[0] = 1e18; for(int i = 1; i <= n; i++){ prg[i] = g[i] + prg[i-1]; prd[i] = d[i] + prd[i-1]; mn[i] = min(mn[i-1], prd[i-1] - x[i]); int left = search(i, prd[i] - x[i]); ans = max(ans, prg[i] - prg[left-1]); } cout << ans << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Runtime error | 1 ms | 492 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Runtime error | 1 ms | 492 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Runtime error | 1 ms | 492 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |