답안 #532305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532305 2022-03-02T17:05:42 Z rainboy 도넛 (JOI14_ho_t3) C
100 / 100
35 ms 2020 KB
#include <stdio.h>

#define N	100000

long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }

long long aa[N + 1];

long long solve2(int l, int r) {
	int lower = l, upper = r;

	while (upper - lower > 1) {
		int j = (lower + upper) / 2;

		if (aa[j] - aa[l] < aa[r] - aa[j])
			lower = j;
		else
			upper = j;
	}
	return l == r ? 0 : max(aa[lower] - aa[l], aa[r] - aa[upper]);
}

int main() {
	int n, i, l, r;
	long long ans;

	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%lld", &aa[i]);
		aa[i] += aa[i - 1];
	}
	ans = 0;
	for (l = 0, r = 0; l < n; l++) {
		while (r < n && solve2(l, r) < aa[n] + aa[l] - aa[r])
			r++;
		ans = max(ans, solve2(l, r - 1));
		if (r < n)
			ans = max(ans, aa[n] + aa[l] - aa[r]);
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

2014_ho_t3.c: In function 'main':
2014_ho_t3.c:28:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
2014_ho_t3.c:30:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%lld", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 3 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 3 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 3 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 3 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 3 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 3 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 32 ms 1756 KB Output is correct
37 Correct 33 ms 2020 KB Output is correct
38 Correct 33 ms 1932 KB Output is correct
39 Correct 33 ms 2004 KB Output is correct
40 Correct 33 ms 2000 KB Output is correct
41 Correct 32 ms 2008 KB Output is correct
42 Correct 35 ms 2000 KB Output is correct
43 Correct 33 ms 1960 KB Output is correct
44 Correct 32 ms 1916 KB Output is correct
45 Correct 33 ms 1996 KB Output is correct
46 Correct 26 ms 1220 KB Output is correct
47 Correct 26 ms 1232 KB Output is correct
48 Correct 23 ms 1248 KB Output is correct