NITK06  MODIFY SEQUENCE
Suppose we have a sequence of nonnegative integers, Namely a_{1}, a_{2}, ..., a_{n}. At each time we can choose one term a_{i} with 0 < i < n and we subtract 1 from both a_{i} and a_{i+1}. We wonder whether we can get a sequence of all zeros after several operations.
Input
The first line is the number of test cases T (0 < T <= 20).
The first line of each test case is a number N (0 < N <= 10000). The next line is N nonnegative integers, 0 <= a_{i} <= 10^{9}.
Output
If it can be modified into all zeros with several operations output “YES” in a single line, otherwise output “NO” instead.
Example
Input: 2 2 1 2 2 2 2 Output: NO YES
Explanation
It is clear that [1 2] can be reduced to [0 1] but no further to convert all integers to 0. Hence, the output is NO.
In second case, output is YES as [2 2] can be reduced to [1 1] and then to [0 0] in just two steps.
hide comments
harsh_ag7654:
20200905 10:45:18
how can 0 4 2 0 2 give yes?


amarjeet16aug:
20200130 21:20:25
Quite simple!!!!!


vivek_dwivedi:
20180615 07:41:38
#very_weak_test_cases... ;) Last edit: 20180615 07:42:40 

pjha573:
20180528 21:44:05
wrong answer accepted 

ameyanator:
20180401 22:06:12
Okay so the test cases are extremly weak. And I wouldn't have even realized if it were not for the comments. Thanks all!


venuraja1432:
20180329 14:35:55
we can do this problem..... without using an array,ie O(1) space 

venuraja1432:
20180329 14:35:55
we can do this problem..... without using an array,ie O(1) space 

prakash1108:
20180115 16:47:42
size of array costed me many WAs 

abhar10:
20171226 18:00:55
AC in One Go !!


sedulous_001:
20170925 17:23:50
Wrong Test cases. It is not supposed to accept the sequence 0 4 2 0 2. As it is not possible to reduce down the sequence into the one with all entries zero. But it is accepting my code which accepts this sequence. :(

Added by:  Gaurav Jain 
Date:  20130925 
Time limit:  0.5s1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 