-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint_Balanced.java
34 lines (34 loc) · 996 Bytes
/
Point_Balanced.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
import java.util.*;
public class Point_Balanced {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int T = in.nextInt();
while(T-->0){
int n = in.nextInt();
long a[] = new long[n];
long sum = 0;
for(int i=0;i<n;i++){
a[i] = in.nextLong();
sum += a[i];
}
boolean check = false;
if(n < 3)
System.out.println("-1");
else{
long sTmp = a[0];
for(int i=1;i<n;i++){
if(sTmp == sum-sTmp-a[i]){
check = true;
System.out.println(i+1);
break;
}
else{
sTmp += a[i];
}
}
if(check == false)
System.out.println("-1");
}
}
}
}