[Link] https://AtCoder.jp/contests/abc238/tasks/abc238_b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.*;
import java.io.*;
public class Main {
static BufferedReader br;
static StringBuilder sb = new StringBuilder();
static int div = 1000000003;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
int n = toi(br.readLine());
int[] a = getArr();
int[] deg = new int[n + 1];
for(int i = 1; i <= n; i++) {
deg[i] = deg[i-1] + a[i - 1];
if(deg[i] >= 360) deg[i] -= 360;
}
Arrays.sort(deg);
int max = -1;
for(int i = 0; i < n; i++) {
max = Math.max(max, deg[i + 1] - deg[i]);
}
max = Math.max(max, 360 - deg[n]);
println(max);
}
static int toi(String s) { return Integer.parseInt(s); }
static String[] getLine() throws IOException { return br.readLine().split(" "); }
static int[] getArr() throws IOException { return Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); }
static <T> void print(T s) { System.out.print(s); }
static <T> void println(T s) { System.out.println(s); }
}