# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259412 | 2020-08-07T18:30:01 Z | ChrisT | Divide and conquer (IZhO14_divide) | C++17 | 78 ms | 8808 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; const int MN = 2e5 + 5, LOG = 18, MOD = 1e9 + 7; ll bit[MN]; vector<ll> xs; int getx (ll x) {return lower_bound(xs.begin(),xs.end(),x) - xs.begin() + 1;} ll x[MN], g[MN], e[MN]; void update (int i, ll v) { for (i=MN-i;i<MN;i+=i&-i) bit[i] = min(bit[i],v); } ll query (int i) { ll ret = 1e18; for (i=MN-i;i;i^=i&-i) ret = min(ret,bit[i]); return ret; } int main () { int n; scanf ("%d",&n); for (int i = 1; i <= n; i++) { scanf ("%lld %lld %lld",&x[i],&g[i],&e[i]); g[i] += g[i-1]; e[i] += e[i-1]; xs.push_back(x[i]-e[i]); xs.push_back(x[i]-e[i-1]); } sort(xs.begin(),xs.end()); xs.erase(unique(xs.begin(),xs.end()),xs.end()); memset(bit,0x3f,sizeof bit); ll ret = -1e18; for (int i = 1; i <= n; i++) { update(getx(x[i]-e[i-1]),g[i-1]); ret = max(ret,g[i] - query(getx(x[i]-e[i]))); } printf ("%lld\n",ret); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1920 KB | Output is correct |
2 | Correct | 1 ms | 1920 KB | Output is correct |
3 | Correct | 1 ms | 2048 KB | Output is correct |
4 | Correct | 1 ms | 1920 KB | Output is correct |
5 | Correct | 1 ms | 1920 KB | Output is correct |
6 | Correct | 1 ms | 1920 KB | Output is correct |
7 | Correct | 1 ms | 1920 KB | Output is correct |
8 | Correct | 1 ms | 1920 KB | Output is correct |
9 | Correct | 2 ms | 1920 KB | Output is correct |
10 | Correct | 1 ms | 1920 KB | Output is correct |
11 | Correct | 1 ms | 1920 KB | Output is correct |
12 | Correct | 1 ms | 1920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1920 KB | Output is correct |
2 | Correct | 1 ms | 1920 KB | Output is correct |
3 | Correct | 1 ms | 2048 KB | Output is correct |
4 | Correct | 1 ms | 1920 KB | Output is correct |
5 | Correct | 1 ms | 1920 KB | Output is correct |
6 | Correct | 1 ms | 1920 KB | Output is correct |
7 | Correct | 1 ms | 1920 KB | Output is correct |
8 | Correct | 1 ms | 1920 KB | Output is correct |
9 | Correct | 2 ms | 1920 KB | Output is correct |
10 | Correct | 1 ms | 1920 KB | Output is correct |
11 | Correct | 1 ms | 1920 KB | Output is correct |
12 | Correct | 1 ms | 1920 KB | Output is correct |
13 | Correct | 1 ms | 1920 KB | Output is correct |
14 | Correct | 1 ms | 1920 KB | Output is correct |
15 | Correct | 2 ms | 1920 KB | Output is correct |
16 | Correct | 2 ms | 1920 KB | Output is correct |
17 | Correct | 3 ms | 1920 KB | Output is correct |
18 | Correct | 2 ms | 2048 KB | Output is correct |
19 | Correct | 2 ms | 1920 KB | Output is correct |
20 | Correct | 2 ms | 1920 KB | Output is correct |
21 | Correct | 2 ms | 2048 KB | Output is correct |
22 | Correct | 2 ms | 2048 KB | Output is correct |
23 | Correct | 5 ms | 2304 KB | Output is correct |
24 | Correct | 5 ms | 2304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1920 KB | Output is correct |
2 | Correct | 1 ms | 1920 KB | Output is correct |
3 | Correct | 1 ms | 2048 KB | Output is correct |
4 | Correct | 1 ms | 1920 KB | Output is correct |
5 | Correct | 1 ms | 1920 KB | Output is correct |
6 | Correct | 1 ms | 1920 KB | Output is correct |
7 | Correct | 1 ms | 1920 KB | Output is correct |
8 | Correct | 1 ms | 1920 KB | Output is correct |
9 | Correct | 2 ms | 1920 KB | Output is correct |
10 | Correct | 1 ms | 1920 KB | Output is correct |
11 | Correct | 1 ms | 1920 KB | Output is correct |
12 | Correct | 1 ms | 1920 KB | Output is correct |
13 | Correct | 1 ms | 1920 KB | Output is correct |
14 | Correct | 1 ms | 1920 KB | Output is correct |
15 | Correct | 2 ms | 1920 KB | Output is correct |
16 | Correct | 2 ms | 1920 KB | Output is correct |
17 | Correct | 3 ms | 1920 KB | Output is correct |
18 | Correct | 2 ms | 2048 KB | Output is correct |
19 | Correct | 2 ms | 1920 KB | Output is correct |
20 | Correct | 2 ms | 1920 KB | Output is correct |
21 | Correct | 2 ms | 2048 KB | Output is correct |
22 | Correct | 2 ms | 2048 KB | Output is correct |
23 | Correct | 5 ms | 2304 KB | Output is correct |
24 | Correct | 5 ms | 2304 KB | Output is correct |
25 | Correct | 4 ms | 2304 KB | Output is correct |
26 | Correct | 7 ms | 2556 KB | Output is correct |
27 | Correct | 8 ms | 2556 KB | Output is correct |
28 | Correct | 33 ms | 5108 KB | Output is correct |
29 | Correct | 37 ms | 5356 KB | Output is correct |
30 | Correct | 78 ms | 8808 KB | Output is correct |
31 | Correct | 64 ms | 7652 KB | Output is correct |
32 | Correct | 76 ms | 7780 KB | Output is correct |
33 | Correct | 78 ms | 7524 KB | Output is correct |
34 | Correct | 63 ms | 7524 KB | Output is correct |
35 | Correct | 67 ms | 8036 KB | Output is correct |
36 | Correct | 69 ms | 8300 KB | Output is correct |