# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1081728 |
2024-08-30T09:38:55 Z |
juicy |
Cigle (COI21_cigle) |
C++17 |
|
147 ms |
81348 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 5e3 + 5;
int n;
int a[N], dp[N][N];
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
int res = 0;
for (int i = 2; i <= n; ++i) {
int k = i - 1, s = a[i - 1], t = 0, cnt = 0;
dp[i][i] = dp[i - 1][i - 1];
for (int j = i + 1; j <= n; ++j) {
dp[i][j] = max(dp[i][j], dp[i][j - 1]);
t += a[j - 1];
while (k && s <= t) {
cnt += s == t;
s += a[--k];
}
if (k) {
dp[i][j] = max(dp[i][j], dp[k][i - 1] + cnt);
}
res = max(res, dp[i][j]);
}
for (int j = 1; j <= i; ++j) {
dp[j][i] = max(dp[j][i], dp[j - 1][i]);
}
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2512 KB |
Output is correct |
20 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9052 KB |
Output is correct |
2 |
Correct |
2 ms |
9052 KB |
Output is correct |
3 |
Correct |
3 ms |
9052 KB |
Output is correct |
4 |
Correct |
1 ms |
9052 KB |
Output is correct |
5 |
Correct |
3 ms |
9052 KB |
Output is correct |
6 |
Correct |
2 ms |
9052 KB |
Output is correct |
7 |
Correct |
3 ms |
9180 KB |
Output is correct |
8 |
Correct |
3 ms |
9168 KB |
Output is correct |
9 |
Correct |
3 ms |
9052 KB |
Output is correct |
10 |
Correct |
2 ms |
9052 KB |
Output is correct |
11 |
Correct |
2 ms |
9052 KB |
Output is correct |
12 |
Correct |
2 ms |
9292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2512 KB |
Output is correct |
20 |
Correct |
1 ms |
2392 KB |
Output is correct |
21 |
Correct |
2 ms |
9052 KB |
Output is correct |
22 |
Correct |
2 ms |
9052 KB |
Output is correct |
23 |
Correct |
3 ms |
9052 KB |
Output is correct |
24 |
Correct |
1 ms |
9052 KB |
Output is correct |
25 |
Correct |
3 ms |
9052 KB |
Output is correct |
26 |
Correct |
2 ms |
9052 KB |
Output is correct |
27 |
Correct |
3 ms |
9180 KB |
Output is correct |
28 |
Correct |
3 ms |
9168 KB |
Output is correct |
29 |
Correct |
3 ms |
9052 KB |
Output is correct |
30 |
Correct |
2 ms |
9052 KB |
Output is correct |
31 |
Correct |
2 ms |
9052 KB |
Output is correct |
32 |
Correct |
2 ms |
9292 KB |
Output is correct |
33 |
Correct |
2 ms |
9052 KB |
Output is correct |
34 |
Correct |
2 ms |
9048 KB |
Output is correct |
35 |
Correct |
2 ms |
9052 KB |
Output is correct |
36 |
Correct |
2 ms |
9048 KB |
Output is correct |
37 |
Correct |
2 ms |
9052 KB |
Output is correct |
38 |
Correct |
2 ms |
9052 KB |
Output is correct |
39 |
Correct |
2 ms |
9052 KB |
Output is correct |
40 |
Correct |
3 ms |
9048 KB |
Output is correct |
41 |
Correct |
2 ms |
9052 KB |
Output is correct |
42 |
Correct |
2 ms |
9168 KB |
Output is correct |
43 |
Correct |
3 ms |
9052 KB |
Output is correct |
44 |
Correct |
2 ms |
9048 KB |
Output is correct |
45 |
Correct |
2 ms |
9052 KB |
Output is correct |
46 |
Correct |
2 ms |
9048 KB |
Output is correct |
47 |
Correct |
2 ms |
9052 KB |
Output is correct |
48 |
Correct |
2 ms |
9048 KB |
Output is correct |
49 |
Correct |
2 ms |
9052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2512 KB |
Output is correct |
20 |
Correct |
1 ms |
2392 KB |
Output is correct |
21 |
Correct |
2 ms |
9052 KB |
Output is correct |
22 |
Correct |
2 ms |
9052 KB |
Output is correct |
23 |
Correct |
3 ms |
9052 KB |
Output is correct |
24 |
Correct |
1 ms |
9052 KB |
Output is correct |
25 |
Correct |
3 ms |
9052 KB |
Output is correct |
26 |
Correct |
2 ms |
9052 KB |
Output is correct |
27 |
Correct |
3 ms |
9180 KB |
Output is correct |
28 |
Correct |
3 ms |
9168 KB |
Output is correct |
29 |
Correct |
3 ms |
9052 KB |
Output is correct |
30 |
Correct |
2 ms |
9052 KB |
Output is correct |
31 |
Correct |
2 ms |
9052 KB |
Output is correct |
32 |
Correct |
2 ms |
9292 KB |
Output is correct |
33 |
Correct |
2 ms |
9052 KB |
Output is correct |
34 |
Correct |
2 ms |
9048 KB |
Output is correct |
35 |
Correct |
2 ms |
9052 KB |
Output is correct |
36 |
Correct |
2 ms |
9048 KB |
Output is correct |
37 |
Correct |
2 ms |
9052 KB |
Output is correct |
38 |
Correct |
2 ms |
9052 KB |
Output is correct |
39 |
Correct |
2 ms |
9052 KB |
Output is correct |
40 |
Correct |
3 ms |
9048 KB |
Output is correct |
41 |
Correct |
2 ms |
9052 KB |
Output is correct |
42 |
Correct |
2 ms |
9168 KB |
Output is correct |
43 |
Correct |
3 ms |
9052 KB |
Output is correct |
44 |
Correct |
2 ms |
9048 KB |
Output is correct |
45 |
Correct |
2 ms |
9052 KB |
Output is correct |
46 |
Correct |
2 ms |
9048 KB |
Output is correct |
47 |
Correct |
2 ms |
9052 KB |
Output is correct |
48 |
Correct |
2 ms |
9048 KB |
Output is correct |
49 |
Correct |
2 ms |
9052 KB |
Output is correct |
50 |
Correct |
116 ms |
79804 KB |
Output is correct |
51 |
Correct |
100 ms |
79772 KB |
Output is correct |
52 |
Correct |
96 ms |
81288 KB |
Output is correct |
53 |
Correct |
109 ms |
79804 KB |
Output is correct |
54 |
Correct |
107 ms |
79872 KB |
Output is correct |
55 |
Correct |
99 ms |
81112 KB |
Output is correct |
56 |
Correct |
118 ms |
79796 KB |
Output is correct |
57 |
Correct |
121 ms |
79956 KB |
Output is correct |
58 |
Correct |
131 ms |
79804 KB |
Output is correct |
59 |
Correct |
135 ms |
81348 KB |
Output is correct |
60 |
Correct |
147 ms |
79864 KB |
Output is correct |
61 |
Correct |
106 ms |
81184 KB |
Output is correct |
62 |
Correct |
122 ms |
79752 KB |
Output is correct |
63 |
Correct |
116 ms |
79836 KB |
Output is correct |
64 |
Correct |
103 ms |
79848 KB |
Output is correct |
65 |
Correct |
94 ms |
79776 KB |
Output is correct |
66 |
Correct |
107 ms |
79956 KB |
Output is correct |
67 |
Correct |
98 ms |
81144 KB |
Output is correct |
68 |
Correct |
130 ms |
78696 KB |
Output is correct |
69 |
Correct |
98 ms |
77304 KB |
Output is correct |
70 |
Correct |
132 ms |
77292 KB |
Output is correct |
71 |
Correct |
139 ms |
77140 KB |
Output is correct |
72 |
Correct |
127 ms |
77396 KB |
Output is correct |