# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334538 | 2020-12-09T11:00:41 Z | Pety | Divide and conquer (IZhO14_divide) | C++14 | 127 ms | 5996 KB |
#include <bits/stdc++.h> using namespace std; int n; int x[100002]; long long g[100002], d[100002], mn[100002]; int cb (int i, long long val) { int st = 1, dr = i, ans; while (st <= dr) { int mij = (st + dr) / 2; if (mn[mij] <= val) { dr = mij - 1; ans = mij; } else st = mij + 1; } return ans; } int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> x[i] >> g[i] >> d[i]; long long ans = 0; mn[0] = 1e18; for (int i = 1; i <= n; i++) { g[i] += g[i - 1]; d[i] += d[i - 1]; mn[i] = min(d[i - 1] - x[i], mn[i - 1]); int poz = cb(i, d[i] - x[i]); ans = max(ans, g[i] - g[poz - 1]); } ///sum[i] - sum[j - 1] - x[i] + x[j] >= 0 ///sum[i] - x[i] >= sum[j - 1] - x[j] cout << ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 2 ms | 364 KB | Output is correct |
18 | Correct | 2 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 364 KB | Output is correct |
22 | Correct | 2 ms | 364 KB | Output is correct |
23 | Correct | 6 ms | 620 KB | Output is correct |
24 | Correct | 6 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 2 ms | 364 KB | Output is correct |
18 | Correct | 2 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 364 KB | Output is correct |
22 | Correct | 2 ms | 364 KB | Output is correct |
23 | Correct | 6 ms | 620 KB | Output is correct |
24 | Correct | 6 ms | 620 KB | Output is correct |
25 | Correct | 4 ms | 492 KB | Output is correct |
26 | Correct | 8 ms | 748 KB | Output is correct |
27 | Correct | 10 ms | 748 KB | Output is correct |
28 | Correct | 50 ms | 2668 KB | Output is correct |
29 | Correct | 59 ms | 3052 KB | Output is correct |
30 | Correct | 127 ms | 5996 KB | Output is correct |
31 | Correct | 90 ms | 4844 KB | Output is correct |
32 | Correct | 93 ms | 4844 KB | Output is correct |
33 | Correct | 89 ms | 4716 KB | Output is correct |
34 | Correct | 90 ms | 4716 KB | Output is correct |
35 | Correct | 104 ms | 5228 KB | Output is correct |
36 | Correct | 124 ms | 5356 KB | Output is correct |