[Solution] Optimal Reduction Codeforces Solution
Consider an array of positive integers.
You may perform the following operation:
- select two indices and (), then
- decrease all elements by .
Let's call the minimum number of operations needed to change array into an array of zeros.
Determine if for all permutations of , is true.
An array is a permutation of an array if consists of the elements of in arbitrary
occupied
order. For example, is a permutation of while is not a permutation of .
The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of the array .
The second line contains integers () — description of the array .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print "YES" (without quotes) if for all permutations of , is true, and "NO" (without quotes) otherwise.
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).
No comments:
Post a Comment