# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
218801 | 2020-04-02T18:29:13 Z | Lawliet | Bigger segments (IZhO19_segments) | C++14 | 112 ms | 38904 KB |
#include <bits/stdc++.h> using namespace std; typedef long long int lli; const int MAXN = 5010; int n; int v[MAXN]; int curMx[MAXN]; int dp[MAXN][MAXN]; lli sv[MAXN]; int main() { scanf("%d",&n); for(int i = 1 ; i <= n ; i++) scanf("%d",&v[i]); for(int i = 1 ; i <= n ; i++) sv[i] = sv[i - 1] + v[i]; for(int i = 1 ; i <= n ; i++) dp[n + 1][i] = 1; for(int i = n ; i > 0 ; i--) { int p = i; for(int j = n ; j >= i ; j--) { curMx[j] = curMx[j + 1]; curMx[j] = max( curMx[j] , dp[j + 1][i] ); } for(int j = i - 1 ; j >= 0 ; j--) { lli lastSum = sv[i - 1] - sv[j - 1]; while( p <= n && sv[p] - sv[i - 1] < lastSum ) p++; dp[i][j] = curMx[p] + 1; } } int ans = 0; for(int i = 1 ; i <= n ; i++) ans = max( ans , dp[i + 1][1] ); printf("%d\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 512 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 512 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 512 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 512 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 7 ms | 2816 KB | Output is correct |
17 | Correct | 6 ms | 2816 KB | Output is correct |
18 | Correct | 7 ms | 2944 KB | Output is correct |
19 | Correct | 6 ms | 2816 KB | Output is correct |
20 | Correct | 7 ms | 2816 KB | Output is correct |
21 | Correct | 7 ms | 2816 KB | Output is correct |
22 | Correct | 6 ms | 2304 KB | Output is correct |
23 | Correct | 6 ms | 1792 KB | Output is correct |
24 | Correct | 7 ms | 2816 KB | Output is correct |
25 | Correct | 6 ms | 2816 KB | Output is correct |
26 | Correct | 6 ms | 2816 KB | Output is correct |
27 | Correct | 6 ms | 2816 KB | Output is correct |
28 | Correct | 7 ms | 2816 KB | Output is correct |
29 | Correct | 7 ms | 2816 KB | Output is correct |
30 | Correct | 7 ms | 2816 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 512 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 512 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 7 ms | 2816 KB | Output is correct |
17 | Correct | 6 ms | 2816 KB | Output is correct |
18 | Correct | 7 ms | 2944 KB | Output is correct |
19 | Correct | 6 ms | 2816 KB | Output is correct |
20 | Correct | 7 ms | 2816 KB | Output is correct |
21 | Correct | 7 ms | 2816 KB | Output is correct |
22 | Correct | 6 ms | 2304 KB | Output is correct |
23 | Correct | 6 ms | 1792 KB | Output is correct |
24 | Correct | 7 ms | 2816 KB | Output is correct |
25 | Correct | 6 ms | 2816 KB | Output is correct |
26 | Correct | 6 ms | 2816 KB | Output is correct |
27 | Correct | 6 ms | 2816 KB | Output is correct |
28 | Correct | 7 ms | 2816 KB | Output is correct |
29 | Correct | 7 ms | 2816 KB | Output is correct |
30 | Correct | 7 ms | 2816 KB | Output is correct |
31 | Correct | 79 ms | 30072 KB | Output is correct |
32 | Correct | 79 ms | 30072 KB | Output is correct |
33 | Correct | 87 ms | 30128 KB | Output is correct |
34 | Correct | 77 ms | 30076 KB | Output is correct |
35 | Correct | 77 ms | 30072 KB | Output is correct |
36 | Correct | 96 ms | 30072 KB | Output is correct |
37 | Correct | 66 ms | 22752 KB | Output is correct |
38 | Correct | 39 ms | 16248 KB | Output is correct |
39 | Correct | 100 ms | 30072 KB | Output is correct |
40 | Correct | 77 ms | 30072 KB | Output is correct |
41 | Correct | 76 ms | 30136 KB | Output is correct |
42 | Correct | 84 ms | 30172 KB | Output is correct |
43 | Correct | 78 ms | 30072 KB | Output is correct |
44 | Correct | 79 ms | 30072 KB | Output is correct |
45 | Correct | 80 ms | 30072 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 512 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 512 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 7 ms | 2816 KB | Output is correct |
17 | Correct | 6 ms | 2816 KB | Output is correct |
18 | Correct | 7 ms | 2944 KB | Output is correct |
19 | Correct | 6 ms | 2816 KB | Output is correct |
20 | Correct | 7 ms | 2816 KB | Output is correct |
21 | Correct | 7 ms | 2816 KB | Output is correct |
22 | Correct | 6 ms | 2304 KB | Output is correct |
23 | Correct | 6 ms | 1792 KB | Output is correct |
24 | Correct | 7 ms | 2816 KB | Output is correct |
25 | Correct | 6 ms | 2816 KB | Output is correct |
26 | Correct | 6 ms | 2816 KB | Output is correct |
27 | Correct | 6 ms | 2816 KB | Output is correct |
28 | Correct | 7 ms | 2816 KB | Output is correct |
29 | Correct | 7 ms | 2816 KB | Output is correct |
30 | Correct | 7 ms | 2816 KB | Output is correct |
31 | Correct | 79 ms | 30072 KB | Output is correct |
32 | Correct | 79 ms | 30072 KB | Output is correct |
33 | Correct | 87 ms | 30128 KB | Output is correct |
34 | Correct | 77 ms | 30076 KB | Output is correct |
35 | Correct | 77 ms | 30072 KB | Output is correct |
36 | Correct | 96 ms | 30072 KB | Output is correct |
37 | Correct | 66 ms | 22752 KB | Output is correct |
38 | Correct | 39 ms | 16248 KB | Output is correct |
39 | Correct | 100 ms | 30072 KB | Output is correct |
40 | Correct | 77 ms | 30072 KB | Output is correct |
41 | Correct | 76 ms | 30136 KB | Output is correct |
42 | Correct | 84 ms | 30172 KB | Output is correct |
43 | Correct | 78 ms | 30072 KB | Output is correct |
44 | Correct | 79 ms | 30072 KB | Output is correct |
45 | Correct | 80 ms | 30072 KB | Output is correct |
46 | Correct | 6 ms | 1536 KB | Output is correct |
47 | Incorrect | 112 ms | 38904 KB | Output isn't correct |
48 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 512 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 512 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 7 ms | 2816 KB | Output is correct |
17 | Correct | 6 ms | 2816 KB | Output is correct |
18 | Correct | 7 ms | 2944 KB | Output is correct |
19 | Correct | 6 ms | 2816 KB | Output is correct |
20 | Correct | 7 ms | 2816 KB | Output is correct |
21 | Correct | 7 ms | 2816 KB | Output is correct |
22 | Correct | 6 ms | 2304 KB | Output is correct |
23 | Correct | 6 ms | 1792 KB | Output is correct |
24 | Correct | 7 ms | 2816 KB | Output is correct |
25 | Correct | 6 ms | 2816 KB | Output is correct |
26 | Correct | 6 ms | 2816 KB | Output is correct |
27 | Correct | 6 ms | 2816 KB | Output is correct |
28 | Correct | 7 ms | 2816 KB | Output is correct |
29 | Correct | 7 ms | 2816 KB | Output is correct |
30 | Correct | 7 ms | 2816 KB | Output is correct |
31 | Correct | 79 ms | 30072 KB | Output is correct |
32 | Correct | 79 ms | 30072 KB | Output is correct |
33 | Correct | 87 ms | 30128 KB | Output is correct |
34 | Correct | 77 ms | 30076 KB | Output is correct |
35 | Correct | 77 ms | 30072 KB | Output is correct |
36 | Correct | 96 ms | 30072 KB | Output is correct |
37 | Correct | 66 ms | 22752 KB | Output is correct |
38 | Correct | 39 ms | 16248 KB | Output is correct |
39 | Correct | 100 ms | 30072 KB | Output is correct |
40 | Correct | 77 ms | 30072 KB | Output is correct |
41 | Correct | 76 ms | 30136 KB | Output is correct |
42 | Correct | 84 ms | 30172 KB | Output is correct |
43 | Correct | 78 ms | 30072 KB | Output is correct |
44 | Correct | 79 ms | 30072 KB | Output is correct |
45 | Correct | 80 ms | 30072 KB | Output is correct |
46 | Correct | 6 ms | 1536 KB | Output is correct |
47 | Incorrect | 112 ms | 38904 KB | Output isn't correct |
48 | Halted | 0 ms | 0 KB | - |