Submission #684890

# Submission time Handle Problem Language Result Execution time Memory
684890 2023-01-22T18:49:27 Z sidon Cigle (COI21_cigle) C++17
100 / 100
645 ms 391820 KB
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define z(X, Y) (X = max(X, Y))

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int N; cin >> N;
	int d[N]; for(int &i : d) cin >> i;

	int dp[N][N] {}, c[N][N] {}, ans {};

	for(int i = 1; i < N; ++i) {
		int sum[2] {}, k = i - 1, cnt {};

		for(int j = i; j < N; ++j) {
			int f = -1;

			for(; k >= 0 && sum[0] + d[k] < sum[1] + d[j]; --k) {
				if((sum[0] += d[k]) == sum[1]) ++cnt, f = k;
			}

			sum[1] += d[j];

			if(f > 0)
				z(dp[i][j], c[f - 1][i-1] + cnt);

			z(dp[i][j], dp[i][j-1]);
			z(ans, dp[i][j]);
		}

		for(int j = 0; j <= i; ++j)
			c[j][i] = dp[j][i];

		for(int j = 1; j <= i; ++j)
			z(c[j][i], c[j-1][i]);
	}

	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 416 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4180 KB Output is correct
2 Correct 3 ms 4180 KB Output is correct
3 Correct 3 ms 4160 KB Output is correct
4 Correct 3 ms 4180 KB Output is correct
5 Correct 3 ms 4180 KB Output is correct
6 Correct 3 ms 4136 KB Output is correct
7 Correct 3 ms 4180 KB Output is correct
8 Correct 4 ms 4180 KB Output is correct
9 Correct 4 ms 4180 KB Output is correct
10 Correct 4 ms 4156 KB Output is correct
11 Correct 4 ms 4180 KB Output is correct
12 Correct 4 ms 4156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 416 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 4 ms 4180 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 3 ms 4160 KB Output is correct
24 Correct 3 ms 4180 KB Output is correct
25 Correct 3 ms 4180 KB Output is correct
26 Correct 3 ms 4136 KB Output is correct
27 Correct 3 ms 4180 KB Output is correct
28 Correct 4 ms 4180 KB Output is correct
29 Correct 4 ms 4180 KB Output is correct
30 Correct 4 ms 4156 KB Output is correct
31 Correct 4 ms 4180 KB Output is correct
32 Correct 4 ms 4156 KB Output is correct
33 Correct 3 ms 4160 KB Output is correct
34 Correct 3 ms 4160 KB Output is correct
35 Correct 3 ms 4180 KB Output is correct
36 Correct 4 ms 4308 KB Output is correct
37 Correct 3 ms 4180 KB Output is correct
38 Correct 4 ms 4180 KB Output is correct
39 Correct 4 ms 4180 KB Output is correct
40 Correct 4 ms 4160 KB Output is correct
41 Correct 4 ms 4180 KB Output is correct
42 Correct 3 ms 4180 KB Output is correct
43 Correct 4 ms 4180 KB Output is correct
44 Correct 3 ms 4160 KB Output is correct
45 Correct 4 ms 4180 KB Output is correct
46 Correct 4 ms 4180 KB Output is correct
47 Correct 3 ms 4152 KB Output is correct
48 Correct 4 ms 4180 KB Output is correct
49 Correct 4 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 416 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 4 ms 4180 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 3 ms 4160 KB Output is correct
24 Correct 3 ms 4180 KB Output is correct
25 Correct 3 ms 4180 KB Output is correct
26 Correct 3 ms 4136 KB Output is correct
27 Correct 3 ms 4180 KB Output is correct
28 Correct 4 ms 4180 KB Output is correct
29 Correct 4 ms 4180 KB Output is correct
30 Correct 4 ms 4156 KB Output is correct
31 Correct 4 ms 4180 KB Output is correct
32 Correct 4 ms 4156 KB Output is correct
33 Correct 3 ms 4160 KB Output is correct
34 Correct 3 ms 4160 KB Output is correct
35 Correct 3 ms 4180 KB Output is correct
36 Correct 4 ms 4308 KB Output is correct
37 Correct 3 ms 4180 KB Output is correct
38 Correct 4 ms 4180 KB Output is correct
39 Correct 4 ms 4180 KB Output is correct
40 Correct 4 ms 4160 KB Output is correct
41 Correct 4 ms 4180 KB Output is correct
42 Correct 3 ms 4180 KB Output is correct
43 Correct 4 ms 4180 KB Output is correct
44 Correct 3 ms 4160 KB Output is correct
45 Correct 4 ms 4180 KB Output is correct
46 Correct 4 ms 4180 KB Output is correct
47 Correct 3 ms 4152 KB Output is correct
48 Correct 4 ms 4180 KB Output is correct
49 Correct 4 ms 4180 KB Output is correct
50 Correct 645 ms 391736 KB Output is correct
51 Correct 586 ms 391748 KB Output is correct
52 Correct 560 ms 391732 KB Output is correct
53 Correct 555 ms 391668 KB Output is correct
54 Correct 560 ms 391740 KB Output is correct
55 Correct 582 ms 391740 KB Output is correct
56 Correct 577 ms 391628 KB Output is correct
57 Correct 586 ms 391736 KB Output is correct
58 Correct 618 ms 391812 KB Output is correct
59 Correct 596 ms 391740 KB Output is correct
60 Correct 580 ms 391668 KB Output is correct
61 Correct 587 ms 391744 KB Output is correct
62 Correct 568 ms 391748 KB Output is correct
63 Correct 552 ms 391744 KB Output is correct
64 Correct 571 ms 391812 KB Output is correct
65 Correct 566 ms 391744 KB Output is correct
66 Correct 585 ms 391756 KB Output is correct
67 Correct 556 ms 391820 KB Output is correct
68 Correct 596 ms 391748 KB Output is correct
69 Correct 548 ms 391740 KB Output is correct
70 Correct 596 ms 391740 KB Output is correct
71 Correct 600 ms 391748 KB Output is correct
72 Correct 572 ms 391744 KB Output is correct