CF1941B.Rudolf and 121
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The first line of the input contains a single integer t ( 1≤t≤104 ) — the number of test cases in the test.
The first line of each case contains a single integer n ( 3≤n≤2⋅105 ) — the number of elements in the array.
The second line of each case contains n integers a1,a2,…,an ( 0≤aj≤109 ) — the elements of the array.
It is guaranteed that the sum of the values of n over all test cases does not exceed 2⋅105 .
输入格式
For each test case, output "YES" if it is possible to make all the elements of the array zero using the described operations. Otherwise, output "NO".
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
输出格式
In the first example, the original array is [1,3,5,5,2] , to make all its elements zero, Rudolf can act as follows:
- apply the operation at i=4 and get the array [1,3,4,3,1] ;
- apply the operation at i=3 and get the array [1,2,2,2,1] ;
- apply the operation at i=2 and get the array [0,0,1,2,1] ;
- apply the operation at i=4 and get the array [0,0,0,0,0] .
输入输出样例
输入#1
7 5 1 3 5 5 2 5 2 4 4 5 1 5 0 1 3 3 1 6 5 6 0 2 3 0 4 1 2 7 2 3 7 1 0 4 1 1 1 1
输出#1
YES NO YES NO NO NO NO
说明/提示
In the first example, the original array is [1,3,5,5,2] , to make all its elements zero, Rudolf can act as follows:
- apply the operation at i=4 and get the array [1,3,4,3,1] ;
- apply the operation at i=3 and get the array [1,2,2,2,1] ;
- apply the operation at i=2 and get the array [0,0,1,2,1] ;
- apply the operation at i=4 and get the array [0,0,0,0,0] .