#K7116. Zero Array Check
Zero Array Check
Zero Array Check
You are given T test cases. In each test case, you are given an integer N and an array of N integers.
Your task is to determine whether it is possible to transform the array such that all its elements become zero by applying a specific set of moves. A key observation is that this transformation is possible if and only if the sum of the array's elements is \(0\). In other words, if \(\sum_{i=1}^{N} a_i = 0\), then the answer is YES
; otherwise, it is NO
.
Note: Although the problem statement mentions a set of moves, you do not need to simulate these moves; simply checking if the sum is zero is sufficient.
inputFormat
The first line contains a single integer T
denoting the number of test cases. For each test case, the input is as follows:
- The first line contains an integer
N
— the number of elements in the array. - The second line contains
N
space-separated integers representing the array elements.
outputFormat
For each test case, output a single line containing YES
if it is possible to make all array elements zero, or NO
otherwise.
5
4
1 2 3 4
2
-1 1
6
1 -1 2 -2 3 -3
6
10 20 -10 -20 30 -30
2
1000000000 -1000000000
NO
YES
YES
YES
YES
</p>