Submission #493277

# Submission time Handle Problem Language Result Execution time Memory
493277 2021-12-10T16:16:22 Z rainboy Cigle (COI21_cigle) C
48 / 100
1000 ms 67240 KB
#include <stdio.h>

#define N	5000

int max(int a, int b) { return a > b ? a : b; }

int main() {
	static int aa[N + 1], dp[N + 1][N + 1];
	int n, i, j, k, l, x, ans;

	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &aa[i]);
		aa[i] += aa[i - 1];
	}
	for (i = 1; i <= n; i++)
		dp[0][i] = 0;
	for (i = 0; i <= n; i++)
		for (j = i + 1; j <= n; j++)
			for (k = j + 1, l = j - 1, x = dp[i][j]; k <= n; k++) {
				dp[j][k] = max(dp[j][k], x);
				while (l >= 0 && aa[k] + aa[l] > aa[j] * 2)
					l--;
				if (l > i && aa[k] + aa[l] == aa[j] * 2)
					x++;
			}
	ans = 0;
	for (i = 0; i < n; i++)
		ans = max(ans, dp[i][n]);
	printf("%d\n", ans);
	return 0;
}

Compilation message

cigle.c: In function 'main':
cigle.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
cigle.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 284 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 284 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2788 KB Output is correct
2 Correct 47 ms 2764 KB Output is correct
3 Correct 50 ms 2764 KB Output is correct
4 Correct 53 ms 2764 KB Output is correct
5 Correct 53 ms 2780 KB Output is correct
6 Correct 97 ms 2776 KB Output is correct
7 Correct 100 ms 2784 KB Output is correct
8 Correct 99 ms 2764 KB Output is correct
9 Correct 103 ms 2780 KB Output is correct
10 Correct 60 ms 2764 KB Output is correct
11 Correct 74 ms 2776 KB Output is correct
12 Correct 63 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 284 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 48 ms 2788 KB Output is correct
22 Correct 47 ms 2764 KB Output is correct
23 Correct 50 ms 2764 KB Output is correct
24 Correct 53 ms 2764 KB Output is correct
25 Correct 53 ms 2780 KB Output is correct
26 Correct 97 ms 2776 KB Output is correct
27 Correct 100 ms 2784 KB Output is correct
28 Correct 99 ms 2764 KB Output is correct
29 Correct 103 ms 2780 KB Output is correct
30 Correct 60 ms 2764 KB Output is correct
31 Correct 74 ms 2776 KB Output is correct
32 Correct 63 ms 2764 KB Output is correct
33 Correct 54 ms 2764 KB Output is correct
34 Correct 50 ms 2764 KB Output is correct
35 Correct 51 ms 2764 KB Output is correct
36 Correct 55 ms 2764 KB Output is correct
37 Correct 98 ms 2780 KB Output is correct
38 Correct 104 ms 2780 KB Output is correct
39 Correct 142 ms 2780 KB Output is correct
40 Correct 150 ms 2780 KB Output is correct
41 Correct 113 ms 2784 KB Output is correct
42 Correct 100 ms 2780 KB Output is correct
43 Correct 88 ms 2788 KB Output is correct
44 Correct 123 ms 2764 KB Output is correct
45 Correct 85 ms 2780 KB Output is correct
46 Correct 87 ms 2764 KB Output is correct
47 Correct 126 ms 2764 KB Output is correct
48 Correct 82 ms 2776 KB Output is correct
49 Correct 81 ms 2780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 284 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 48 ms 2788 KB Output is correct
22 Correct 47 ms 2764 KB Output is correct
23 Correct 50 ms 2764 KB Output is correct
24 Correct 53 ms 2764 KB Output is correct
25 Correct 53 ms 2780 KB Output is correct
26 Correct 97 ms 2776 KB Output is correct
27 Correct 100 ms 2784 KB Output is correct
28 Correct 99 ms 2764 KB Output is correct
29 Correct 103 ms 2780 KB Output is correct
30 Correct 60 ms 2764 KB Output is correct
31 Correct 74 ms 2776 KB Output is correct
32 Correct 63 ms 2764 KB Output is correct
33 Correct 54 ms 2764 KB Output is correct
34 Correct 50 ms 2764 KB Output is correct
35 Correct 51 ms 2764 KB Output is correct
36 Correct 55 ms 2764 KB Output is correct
37 Correct 98 ms 2780 KB Output is correct
38 Correct 104 ms 2780 KB Output is correct
39 Correct 142 ms 2780 KB Output is correct
40 Correct 150 ms 2780 KB Output is correct
41 Correct 113 ms 2784 KB Output is correct
42 Correct 100 ms 2780 KB Output is correct
43 Correct 88 ms 2788 KB Output is correct
44 Correct 123 ms 2764 KB Output is correct
45 Correct 85 ms 2780 KB Output is correct
46 Correct 87 ms 2764 KB Output is correct
47 Correct 126 ms 2764 KB Output is correct
48 Correct 82 ms 2776 KB Output is correct
49 Correct 81 ms 2780 KB Output is correct
50 Execution timed out 1091 ms 67240 KB Time limit exceeded
51 Halted 0 ms 0 KB -