# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
290817 | 2020-09-04T13:18:08 Z | PeppaPig | Bigger segments (IZhO19_segments) | C++14 | 308 ms | 41592 KB |
#include <bits/stdc++.h> #define long long long #define pii pair<long, long> #define x first #define y second using namespace std; const int N = 5e5 + 5; int n, dp[N]; long A[N], pref[N]; int main() { scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%lld", A + i); pref[i] = pref[i - 1] + A[i]; } set<pii, greater<pii> > S; S.emplace(0, 0); for(int i = 1; i <= n; i++) { auto it = S.lower_bound(pii(pref[i], 1e9)); dp[i] = dp[it->y] + 1; long val = 2ll * pref[i] - pref[it->y]; auto now = S.begin(); while(now != S.end()) { if(now->x >= val) now = S.erase(now); else break; } S.emplace(val, i); } printf("%d\n", dp[n]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 404 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 404 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 1 ms | 768 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 512 KB | Output is correct |
35 | Correct | 2 ms | 640 KB | Output is correct |
36 | Correct | 3 ms | 544 KB | Output is correct |
37 | Correct | 1 ms | 512 KB | Output is correct |
38 | Correct | 2 ms | 512 KB | Output is correct |
39 | Correct | 1 ms | 512 KB | Output is correct |
40 | Correct | 2 ms | 512 KB | Output is correct |
41 | Correct | 2 ms | 640 KB | Output is correct |
42 | Correct | 1 ms | 512 KB | Output is correct |
43 | Correct | 1 ms | 512 KB | Output is correct |
44 | Correct | 1 ms | 640 KB | Output is correct |
45 | Correct | 2 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 404 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 1 ms | 768 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 512 KB | Output is correct |
35 | Correct | 2 ms | 640 KB | Output is correct |
36 | Correct | 3 ms | 544 KB | Output is correct |
37 | Correct | 1 ms | 512 KB | Output is correct |
38 | Correct | 2 ms | 512 KB | Output is correct |
39 | Correct | 1 ms | 512 KB | Output is correct |
40 | Correct | 2 ms | 512 KB | Output is correct |
41 | Correct | 2 ms | 640 KB | Output is correct |
42 | Correct | 1 ms | 512 KB | Output is correct |
43 | Correct | 1 ms | 512 KB | Output is correct |
44 | Correct | 1 ms | 640 KB | Output is correct |
45 | Correct | 2 ms | 512 KB | Output is correct |
46 | Correct | 41 ms | 8568 KB | Output is correct |
47 | Correct | 43 ms | 6520 KB | Output is correct |
48 | Correct | 39 ms | 2680 KB | Output is correct |
49 | Correct | 55 ms | 5752 KB | Output is correct |
50 | Correct | 53 ms | 8568 KB | Output is correct |
51 | Correct | 58 ms | 7240 KB | Output is correct |
52 | Correct | 26 ms | 3832 KB | Output is correct |
53 | Correct | 15 ms | 2432 KB | Output is correct |
54 | Correct | 45 ms | 6904 KB | Output is correct |
55 | Correct | 54 ms | 7960 KB | Output is correct |
56 | Correct | 49 ms | 8568 KB | Output is correct |
57 | Correct | 47 ms | 8056 KB | Output is correct |
58 | Correct | 47 ms | 7928 KB | Output is correct |
59 | Correct | 50 ms | 8568 KB | Output is correct |
60 | Correct | 52 ms | 8568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 404 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 1 ms | 768 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 512 KB | Output is correct |
35 | Correct | 2 ms | 640 KB | Output is correct |
36 | Correct | 3 ms | 544 KB | Output is correct |
37 | Correct | 1 ms | 512 KB | Output is correct |
38 | Correct | 2 ms | 512 KB | Output is correct |
39 | Correct | 1 ms | 512 KB | Output is correct |
40 | Correct | 2 ms | 512 KB | Output is correct |
41 | Correct | 2 ms | 640 KB | Output is correct |
42 | Correct | 1 ms | 512 KB | Output is correct |
43 | Correct | 1 ms | 512 KB | Output is correct |
44 | Correct | 1 ms | 640 KB | Output is correct |
45 | Correct | 2 ms | 512 KB | Output is correct |
46 | Correct | 41 ms | 8568 KB | Output is correct |
47 | Correct | 43 ms | 6520 KB | Output is correct |
48 | Correct | 39 ms | 2680 KB | Output is correct |
49 | Correct | 55 ms | 5752 KB | Output is correct |
50 | Correct | 53 ms | 8568 KB | Output is correct |
51 | Correct | 58 ms | 7240 KB | Output is correct |
52 | Correct | 26 ms | 3832 KB | Output is correct |
53 | Correct | 15 ms | 2432 KB | Output is correct |
54 | Correct | 45 ms | 6904 KB | Output is correct |
55 | Correct | 54 ms | 7960 KB | Output is correct |
56 | Correct | 49 ms | 8568 KB | Output is correct |
57 | Correct | 47 ms | 8056 KB | Output is correct |
58 | Correct | 47 ms | 7928 KB | Output is correct |
59 | Correct | 50 ms | 8568 KB | Output is correct |
60 | Correct | 52 ms | 8568 KB | Output is correct |
61 | Correct | 245 ms | 41440 KB | Output is correct |
62 | Correct | 240 ms | 41376 KB | Output is correct |
63 | Correct | 240 ms | 33016 KB | Output is correct |
64 | Correct | 266 ms | 16376 KB | Output is correct |
65 | Correct | 308 ms | 41464 KB | Output is correct |
66 | Correct | 300 ms | 35020 KB | Output is correct |
67 | Correct | 246 ms | 28168 KB | Output is correct |
68 | Correct | 115 ms | 14200 KB | Output is correct |
69 | Correct | 257 ms | 32956 KB | Output is correct |
70 | Correct | 297 ms | 39032 KB | Output is correct |
71 | Correct | 272 ms | 41468 KB | Output is correct |
72 | Correct | 252 ms | 35192 KB | Output is correct |
73 | Correct | 270 ms | 36800 KB | Output is correct |
74 | Correct | 289 ms | 41592 KB | Output is correct |
75 | Correct | 281 ms | 41592 KB | Output is correct |