# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42473 | 2018-02-27T15:25:09 Z | MatheusLealV | Divide and conquer (IZhO14_divide) | C++14 | 248 ms | 30860 KB |
#include <bits/stdc++.h> #define N 200050 #define f first using namespace std; typedef long long ll; int cnt; ll n, sum[N], g[N], x[N], E[N], dp[N], ans, bit[N]; vector<ll> v; map<ll, ll> mapa; void upd(int x, ll v) { for(int i = x; i < N; i += (i&-i)) bit[i] = min(bit[i], v); } int query(int x) { ll sum = 2000000000000000000LL; for(int i = x; i > 0; i -= (i&-i)) sum = min(sum, bit[i]); return sum; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin>>n; for(int i = 1, a, b, c; i <= n; i++) { cin>>x[i]>>g[i]>>E[i]; sum[i] = E[i] + sum[i - 1]; g[i] += g[i - 1]; v.push_back(sum[i] - x[i]); v.push_back(sum[i - 1] - x[i]); } for(int i = 0; i < N; i++) bit[i] = 2000000000000000000LL; sort(v.begin(), v.end()); for(auto x: v) if(!mapa[x]) mapa[x] = ++cnt; for(int i = 1; i <= n; i++) { upd( mapa [ sum[i - 1] - x[i] ], g[i - 1]); ll q = g[i] - query( mapa[ sum[i] - x[i] ] ); ans = max(ans, q); } cout<<ans<<"\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1912 KB | Output is correct |
2 | Correct | 2 ms | 2016 KB | Output is correct |
3 | Correct | 2 ms | 2076 KB | Output is correct |
4 | Correct | 3 ms | 2124 KB | Output is correct |
5 | Correct | 3 ms | 2196 KB | Output is correct |
6 | Incorrect | 2 ms | 2196 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2196 KB | Output is correct |
2 | Correct | 3 ms | 2196 KB | Output is correct |
3 | Correct | 3 ms | 2284 KB | Output is correct |
4 | Correct | 4 ms | 2284 KB | Output is correct |
5 | Incorrect | 3 ms | 2288 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 3056 KB | Output is correct |
2 | Correct | 17 ms | 3856 KB | Output is correct |
3 | Correct | 17 ms | 3936 KB | Output is correct |
4 | Correct | 104 ms | 10852 KB | Output is correct |
5 | Correct | 118 ms | 12132 KB | Output is correct |
6 | Correct | 248 ms | 23776 KB | Output is correct |
7 | Correct | 235 ms | 25764 KB | Output is correct |
8 | Correct | 230 ms | 27568 KB | Output is correct |
9 | Correct | 239 ms | 29360 KB | Output is correct |
10 | Incorrect | 218 ms | 30860 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |