Array Differentiation solution codeforces
You are given a sequence ofintegers .
Does there exist a sequence ofintegers such that the following property holds?
- For each , there exist two (not necessarily distinct) indices and ( ) such that .
The first line contains a single integer( ) — the number of test cases. Then test cases follow.
The first line of each test case contains one integer( ).
The second line of each test case contains theintegers ( ).
For each test case, output a line containing YES if a sequence satisfying the required property exists, and NO otherwise.
5 5 4 -7 -1 5 10 1 0 3 1 10 100 4 -3 2 10 2 9 25 -171 250 174 152 242 100 -205 -258
YES YES NO YES YES
In the first test case, the sequence satisfies the property. Indeed, the following holds:
In the second test case, it is sufficient to choose , since .
In the third test case, it is possible to show that no sequence of length satisfies the property.