Submission #544722

# Submission time Handle Problem Language Result Execution time Memory
544722 2022-04-02T16:10:58 Z rainboy Hacker (BOI15_hac) C
100 / 100
75 ms 7224 KB
#include <stdio.h>

#define N	500000

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

int main() {
	static int aa[N], ss[N], qu[N * 2];
	int n, k, i, head, cnt, ans;

	scanf("%d", &n), k = (n + 1) / 2;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		if (i * 2 < n)
			ss[0] += aa[i];
	}
	for (i = 1; i < n; i++)
		ss[i] = ss[i - 1] - aa[i - 1] + aa[(i + k - 1) % n];
	head = cnt = 0, ans = 0;
	for (i = 0; i < n + k; i++) {
		while (cnt && ss[qu[head + cnt - 1] % n] >= ss[i % n])
			cnt--;
		qu[head + cnt++] = i;
		if (i >= k - 1) {
			ans = max(ans, ss[qu[head] % n]);
			if (qu[head] == i - k + 1)
				head++, cnt--;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

hac.c: In function 'main':
hac.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n), k = (n + 1) / 2;
      |  ^~~~~~~~~~~~~~~
hac.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 0 ms 212 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
3 Correct 0 ms 292 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 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 0 ms 292 KB Output is correct
3 Correct 0 ms 292 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 224 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 292 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 13 ms 1200 KB Output is correct
5 Correct 29 ms 2604 KB Output is correct
6 Correct 38 ms 3220 KB Output is correct
7 Correct 45 ms 4000 KB Output is correct
8 Correct 75 ms 6348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
3 Correct 0 ms 292 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 224 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 292 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 304 KB Output is correct
35 Correct 13 ms 1200 KB Output is correct
36 Correct 29 ms 2604 KB Output is correct
37 Correct 38 ms 3220 KB Output is correct
38 Correct 45 ms 4000 KB Output is correct
39 Correct 75 ms 6348 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 5 ms 668 KB Output is correct
43 Correct 31 ms 2656 KB Output is correct
44 Correct 72 ms 6364 KB Output is correct
45 Correct 15 ms 1372 KB Output is correct
46 Correct 45 ms 3888 KB Output is correct
47 Correct 75 ms 6372 KB Output is correct
48 Correct 63 ms 6604 KB Output is correct
49 Correct 62 ms 7224 KB Output is correct
50 Correct 62 ms 7188 KB Output is correct