#include <stdio.h>
#define N 8000
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; }
int main() {
static long long aa[N + 1];
int n, i, j, k;
long long ans;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%lld", &aa[i]);
aa[i] += aa[i - 1];
}
ans = 0;
for (i = 0; i < n; i++)
for (j = i + 1, k = i + 1; k < n; k++) {
while (j < n && aa[j] - aa[i] < aa[k] - aa[j])
j++;
ans = max(ans, min(max(aa[j - 1] - aa[i], aa[k] - aa[j]), aa[n] + aa[i] - aa[k]));
}
printf("%lld\n", ans);
return 0;
}
Compilation message
2014_ho_t3.c: In function 'main':
2014_ho_t3.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
2014_ho_t3.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%lld", &aa[i]);
| ^~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
284 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
284 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
284 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
284 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
284 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
284 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
284 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
240 ms |
360 KB |
Output is correct |
22 |
Correct |
205 ms |
360 KB |
Output is correct |
23 |
Correct |
210 ms |
372 KB |
Output is correct |
24 |
Correct |
215 ms |
356 KB |
Output is correct |
25 |
Correct |
211 ms |
360 KB |
Output is correct |
26 |
Correct |
209 ms |
456 KB |
Output is correct |
27 |
Correct |
209 ms |
404 KB |
Output is correct |
28 |
Correct |
264 ms |
400 KB |
Output is correct |
29 |
Correct |
217 ms |
396 KB |
Output is correct |
30 |
Correct |
205 ms |
400 KB |
Output is correct |
31 |
Correct |
180 ms |
336 KB |
Output is correct |
32 |
Correct |
171 ms |
336 KB |
Output is correct |
33 |
Correct |
176 ms |
332 KB |
Output is correct |
34 |
Correct |
194 ms |
340 KB |
Output is correct |
35 |
Correct |
171 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
284 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
284 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
284 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
240 ms |
360 KB |
Output is correct |
22 |
Correct |
205 ms |
360 KB |
Output is correct |
23 |
Correct |
210 ms |
372 KB |
Output is correct |
24 |
Correct |
215 ms |
356 KB |
Output is correct |
25 |
Correct |
211 ms |
360 KB |
Output is correct |
26 |
Correct |
209 ms |
456 KB |
Output is correct |
27 |
Correct |
209 ms |
404 KB |
Output is correct |
28 |
Correct |
264 ms |
400 KB |
Output is correct |
29 |
Correct |
217 ms |
396 KB |
Output is correct |
30 |
Correct |
205 ms |
400 KB |
Output is correct |
31 |
Correct |
180 ms |
336 KB |
Output is correct |
32 |
Correct |
171 ms |
336 KB |
Output is correct |
33 |
Correct |
176 ms |
332 KB |
Output is correct |
34 |
Correct |
194 ms |
340 KB |
Output is correct |
35 |
Correct |
171 ms |
336 KB |
Output is correct |
36 |
Runtime error |
2 ms |
712 KB |
Execution killed with signal 11 |
37 |
Halted |
0 ms |
0 KB |
- |