import java.util.*;
import java.io.*;
public class hac {
// https://oj.uz/problem/view/BOI15_hac
public static void main(String[] args) throws IOException, FileNotFoundException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//BufferedReader in = new BufferedReader(new FileReader("HAC"));
int n = Integer.parseInt(in.readLine());
long[] arr = new long[n];
StringTokenizer st = new StringTokenizer(in.readLine());
for (int i=0; i<n; i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
ArrayList<Long> sums = new ArrayList<Long>();
long sum=0;
int k = (n+1)/2;
for (int i=0; i<k; i++) {
sum += arr[i];
}
sums.add(sum);
for (int i=0; i<n-1; i++) {
sum -= arr[i];
sum += (arr[(i+k)%n]);
sums.add(sum);
}
long ans=Math.min(sums.get(sums.size()-1), sums.get(0));
for (int i=0; i<sums.size()-1; i++) {
ans = Math.max(ans, Math.min(sums.get(i), sums.get(i+1)));
}
System.out.println(ans);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
8556 KB |
Output is correct |
2 |
Incorrect |
88 ms |
8572 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
8556 KB |
Output is correct |
2 |
Incorrect |
88 ms |
8572 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
8428 KB |
Output is correct |
2 |
Incorrect |
88 ms |
8824 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
8556 KB |
Output is correct |
2 |
Incorrect |
88 ms |
8572 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |