# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
420488 |
2021-06-08T11:48:27 Z |
Berted |
Cigle (COI21_cigle) |
C++14 |
|
1000 ms |
108120 KB |
#include <iostream>
using namespace std;
int N, A[5001];
int cst[5001][5001], DP[5001][5001];
int main()
{
cin >> N;
for (int i = 0; i < N; i++) cin >> A[i];
for (int i = 0; i < N; i++)
{
int sumL = 0, sumR = 0, l = i - 1, r = i;
while (l >= 0 && r < N)
{
if (sumL + A[l] < sumR + A[r]) {sumL += A[l--];}
else {sumR += A[r++];}
if (l >= 0 && r < N && sumL == sumR) {cst[i][l] = 1; cst[i][r] = 1;}
}
for (int j = i + 1; j < N; j++) cst[i][j] = cst[i][j - 1] + cst[i][j];
for (int j = i - 2; j >= 0; j--) cst[i][j] = cst[i][j + 1] + cst[i][j];
}
for (int i = 0; i < N; i++)
{
for (int j = 0; j <= i; j++)
{
//cerr << i << " " << j << " DP\n";
for (int k = j - 1; k >= 0; k--)
{
DP[i][j] = max(DP[i][j], DP[j - 1][k] + min(cst[j][i], cst[j][k]));
//cerr << j - 1 << " " << k << " " << DP[j - 1][k] << " " << min(cst[j][i], cst[j][k]) << "\n";
}
//cerr << "DPF: " << i << " " << j << " " << DP[i][j] << "\n";
}
}
int res = 0;
for (int i = 0; i < N; i++) {res = max(res, DP[N - 1][i]);}
cout << res << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
972 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
1 ms |
972 KB |
Output is correct |
15 |
Correct |
1 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
972 KB |
Output is correct |
17 |
Correct |
1 ms |
972 KB |
Output is correct |
18 |
Correct |
1 ms |
972 KB |
Output is correct |
19 |
Correct |
2 ms |
972 KB |
Output is correct |
20 |
Correct |
1 ms |
928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
5696 KB |
Output is correct |
2 |
Correct |
38 ms |
5696 KB |
Output is correct |
3 |
Correct |
38 ms |
5744 KB |
Output is correct |
4 |
Correct |
39 ms |
5728 KB |
Output is correct |
5 |
Correct |
40 ms |
5700 KB |
Output is correct |
6 |
Correct |
40 ms |
5760 KB |
Output is correct |
7 |
Correct |
39 ms |
5740 KB |
Output is correct |
8 |
Correct |
44 ms |
5704 KB |
Output is correct |
9 |
Correct |
40 ms |
5704 KB |
Output is correct |
10 |
Correct |
39 ms |
5760 KB |
Output is correct |
11 |
Correct |
43 ms |
5772 KB |
Output is correct |
12 |
Correct |
39 ms |
5732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
972 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
1 ms |
972 KB |
Output is correct |
15 |
Correct |
1 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
972 KB |
Output is correct |
17 |
Correct |
1 ms |
972 KB |
Output is correct |
18 |
Correct |
1 ms |
972 KB |
Output is correct |
19 |
Correct |
2 ms |
972 KB |
Output is correct |
20 |
Correct |
1 ms |
928 KB |
Output is correct |
21 |
Correct |
38 ms |
5696 KB |
Output is correct |
22 |
Correct |
38 ms |
5696 KB |
Output is correct |
23 |
Correct |
38 ms |
5744 KB |
Output is correct |
24 |
Correct |
39 ms |
5728 KB |
Output is correct |
25 |
Correct |
40 ms |
5700 KB |
Output is correct |
26 |
Correct |
40 ms |
5760 KB |
Output is correct |
27 |
Correct |
39 ms |
5740 KB |
Output is correct |
28 |
Correct |
44 ms |
5704 KB |
Output is correct |
29 |
Correct |
40 ms |
5704 KB |
Output is correct |
30 |
Correct |
39 ms |
5760 KB |
Output is correct |
31 |
Correct |
43 ms |
5772 KB |
Output is correct |
32 |
Correct |
39 ms |
5732 KB |
Output is correct |
33 |
Correct |
41 ms |
5776 KB |
Output is correct |
34 |
Correct |
40 ms |
5800 KB |
Output is correct |
35 |
Correct |
54 ms |
5788 KB |
Output is correct |
36 |
Correct |
41 ms |
5792 KB |
Output is correct |
37 |
Correct |
40 ms |
5680 KB |
Output is correct |
38 |
Correct |
39 ms |
5752 KB |
Output is correct |
39 |
Correct |
39 ms |
5712 KB |
Output is correct |
40 |
Correct |
41 ms |
5720 KB |
Output is correct |
41 |
Correct |
50 ms |
5756 KB |
Output is correct |
42 |
Correct |
40 ms |
5764 KB |
Output is correct |
43 |
Correct |
41 ms |
5700 KB |
Output is correct |
44 |
Correct |
41 ms |
5792 KB |
Output is correct |
45 |
Correct |
39 ms |
5724 KB |
Output is correct |
46 |
Correct |
40 ms |
5700 KB |
Output is correct |
47 |
Correct |
43 ms |
5664 KB |
Output is correct |
48 |
Correct |
38 ms |
5732 KB |
Output is correct |
49 |
Correct |
39 ms |
5780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
972 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
1 ms |
972 KB |
Output is correct |
15 |
Correct |
1 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
972 KB |
Output is correct |
17 |
Correct |
1 ms |
972 KB |
Output is correct |
18 |
Correct |
1 ms |
972 KB |
Output is correct |
19 |
Correct |
2 ms |
972 KB |
Output is correct |
20 |
Correct |
1 ms |
928 KB |
Output is correct |
21 |
Correct |
38 ms |
5696 KB |
Output is correct |
22 |
Correct |
38 ms |
5696 KB |
Output is correct |
23 |
Correct |
38 ms |
5744 KB |
Output is correct |
24 |
Correct |
39 ms |
5728 KB |
Output is correct |
25 |
Correct |
40 ms |
5700 KB |
Output is correct |
26 |
Correct |
40 ms |
5760 KB |
Output is correct |
27 |
Correct |
39 ms |
5740 KB |
Output is correct |
28 |
Correct |
44 ms |
5704 KB |
Output is correct |
29 |
Correct |
40 ms |
5704 KB |
Output is correct |
30 |
Correct |
39 ms |
5760 KB |
Output is correct |
31 |
Correct |
43 ms |
5772 KB |
Output is correct |
32 |
Correct |
39 ms |
5732 KB |
Output is correct |
33 |
Correct |
41 ms |
5776 KB |
Output is correct |
34 |
Correct |
40 ms |
5800 KB |
Output is correct |
35 |
Correct |
54 ms |
5788 KB |
Output is correct |
36 |
Correct |
41 ms |
5792 KB |
Output is correct |
37 |
Correct |
40 ms |
5680 KB |
Output is correct |
38 |
Correct |
39 ms |
5752 KB |
Output is correct |
39 |
Correct |
39 ms |
5712 KB |
Output is correct |
40 |
Correct |
41 ms |
5720 KB |
Output is correct |
41 |
Correct |
50 ms |
5756 KB |
Output is correct |
42 |
Correct |
40 ms |
5764 KB |
Output is correct |
43 |
Correct |
41 ms |
5700 KB |
Output is correct |
44 |
Correct |
41 ms |
5792 KB |
Output is correct |
45 |
Correct |
39 ms |
5724 KB |
Output is correct |
46 |
Correct |
40 ms |
5700 KB |
Output is correct |
47 |
Correct |
43 ms |
5664 KB |
Output is correct |
48 |
Correct |
38 ms |
5732 KB |
Output is correct |
49 |
Correct |
39 ms |
5780 KB |
Output is correct |
50 |
Execution timed out |
1055 ms |
108120 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |