-
Notifications
You must be signed in to change notification settings - Fork 0
/
cf_round918_E.java
42 lines (41 loc) · 1.14 KB
/
cf_round918_E.java
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
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
public class cf_round918_E {
public static boolean isEven(int n){
if(n % 2 == 0){
return true;
}
return false;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t --> 0) {
long n = sc.nextLong();
int res = 0;
Map<Long, Long> map = new HashMap<>();
int total_size = (int)n;
long arr[] = new long[total_size];
for (int i=0; i<n; i++) {
arr[i] = sc.nextLong();
}
map.put(0L, 1L);
long sum = 0;
for (int i = 0; i < n; i++) {
if (isEven(i)) {
sum += arr[i];
} else {
sum -= arr[i];
}
if (map.containsKey(sum))
res = 1;
else
map.put(sum, 1L);
}
if (res == 1) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}