답안 #493280

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493280 2021-12-10T16:58:03 Z rainboy Cigle (COI21_cigle) C
100 / 100
263 ms 67404 KB
#include <stdio.h>
#include <string.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], dq[N + 1];
	int n, i, j, k, x, c, 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 (j = 1; j <= n; j++) {
		for (i = 0; i < j; i++)
			dq[i] = dp[i][j];
		for (i = 1; i < j; i++)
			dq[i] = max(dq[i], dq[i - 1]);
		x = 0, c = 0;
		for (i = j - 1, k = j + 1; k <= n; k++) {
			dp[j][k] = x;
			while (i >= 0 && aa[i] + aa[k] > aa[j] * 2)
				i--;
			if (i > 0 && aa[i] + aa[k] == aa[j] * 2)
				x = max(x, dq[i - 1] + ++c);
		}
	}
	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:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
cigle.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 288 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 288 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 284 KB Output is correct
10 Correct 0 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 0 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2764 KB Output is correct
2 Correct 3 ms 2764 KB Output is correct
3 Correct 2 ms 2728 KB Output is correct
4 Correct 2 ms 2764 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 3 ms 2764 KB Output is correct
7 Correct 3 ms 2704 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 3 ms 2764 KB Output is correct
10 Correct 2 ms 2764 KB Output is correct
11 Correct 2 ms 2764 KB Output is correct
12 Correct 2 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 288 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 284 KB Output is correct
10 Correct 0 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 0 ms 588 KB Output is correct
21 Correct 2 ms 2764 KB Output is correct
22 Correct 3 ms 2764 KB Output is correct
23 Correct 2 ms 2728 KB Output is correct
24 Correct 2 ms 2764 KB Output is correct
25 Correct 2 ms 2764 KB Output is correct
26 Correct 3 ms 2764 KB Output is correct
27 Correct 3 ms 2704 KB Output is correct
28 Correct 2 ms 2764 KB Output is correct
29 Correct 3 ms 2764 KB Output is correct
30 Correct 2 ms 2764 KB Output is correct
31 Correct 2 ms 2764 KB Output is correct
32 Correct 2 ms 2764 KB Output is correct
33 Correct 2 ms 2764 KB Output is correct
34 Correct 2 ms 2764 KB Output is correct
35 Correct 2 ms 2764 KB Output is correct
36 Correct 2 ms 2764 KB Output is correct
37 Correct 3 ms 2764 KB Output is correct
38 Correct 2 ms 2764 KB Output is correct
39 Correct 3 ms 2764 KB Output is correct
40 Correct 2 ms 2764 KB Output is correct
41 Correct 2 ms 2792 KB Output is correct
42 Correct 2 ms 2756 KB Output is correct
43 Correct 3 ms 2764 KB Output is correct
44 Correct 3 ms 2764 KB Output is correct
45 Correct 3 ms 2764 KB Output is correct
46 Correct 3 ms 2764 KB Output is correct
47 Correct 3 ms 2764 KB Output is correct
48 Correct 2 ms 2764 KB Output is correct
49 Correct 2 ms 2776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 288 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 284 KB Output is correct
10 Correct 0 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 0 ms 588 KB Output is correct
21 Correct 2 ms 2764 KB Output is correct
22 Correct 3 ms 2764 KB Output is correct
23 Correct 2 ms 2728 KB Output is correct
24 Correct 2 ms 2764 KB Output is correct
25 Correct 2 ms 2764 KB Output is correct
26 Correct 3 ms 2764 KB Output is correct
27 Correct 3 ms 2704 KB Output is correct
28 Correct 2 ms 2764 KB Output is correct
29 Correct 3 ms 2764 KB Output is correct
30 Correct 2 ms 2764 KB Output is correct
31 Correct 2 ms 2764 KB Output is correct
32 Correct 2 ms 2764 KB Output is correct
33 Correct 2 ms 2764 KB Output is correct
34 Correct 2 ms 2764 KB Output is correct
35 Correct 2 ms 2764 KB Output is correct
36 Correct 2 ms 2764 KB Output is correct
37 Correct 3 ms 2764 KB Output is correct
38 Correct 2 ms 2764 KB Output is correct
39 Correct 3 ms 2764 KB Output is correct
40 Correct 2 ms 2764 KB Output is correct
41 Correct 2 ms 2792 KB Output is correct
42 Correct 2 ms 2756 KB Output is correct
43 Correct 3 ms 2764 KB Output is correct
44 Correct 3 ms 2764 KB Output is correct
45 Correct 3 ms 2764 KB Output is correct
46 Correct 3 ms 2764 KB Output is correct
47 Correct 3 ms 2764 KB Output is correct
48 Correct 2 ms 2764 KB Output is correct
49 Correct 2 ms 2776 KB Output is correct
50 Correct 221 ms 67280 KB Output is correct
51 Correct 237 ms 67404 KB Output is correct
52 Correct 223 ms 67252 KB Output is correct
53 Correct 221 ms 67372 KB Output is correct
54 Correct 229 ms 67204 KB Output is correct
55 Correct 226 ms 67216 KB Output is correct
56 Correct 254 ms 67380 KB Output is correct
57 Correct 257 ms 67204 KB Output is correct
58 Correct 260 ms 67236 KB Output is correct
59 Correct 261 ms 67264 KB Output is correct
60 Correct 254 ms 67292 KB Output is correct
61 Correct 244 ms 67256 KB Output is correct
62 Correct 240 ms 67208 KB Output is correct
63 Correct 240 ms 67236 KB Output is correct
64 Correct 234 ms 67228 KB Output is correct
65 Correct 229 ms 67276 KB Output is correct
66 Correct 232 ms 67188 KB Output is correct
67 Correct 218 ms 67268 KB Output is correct
68 Correct 216 ms 67276 KB Output is correct
69 Correct 218 ms 67196 KB Output is correct
70 Correct 247 ms 67228 KB Output is correct
71 Correct 263 ms 67236 KB Output is correct
72 Correct 249 ms 67248 KB Output is correct