Careless Chef solution codechef
Chef has a sequence of integersof length . He creates another sequence of length using sequence . Initially, is empty. Chef performs the following process.
For each elementof :
- Choose any arbitrary integer (Note that the value of can be different for different elements).
- Add and to .
Chef then shuffles the sequencerandomly after this process.
Since Chef is careless, he lost bothand and now only vaguely remembers the elements of . Chef would like to know if the sequence (which he vaguely remembers) can be correct or not. Can you help him?
Formally, you are provided with a sequenceof size . You are required to tell if the provided sequence can be achieved from any sequence of size using the given process or not.
Input Format Careless Chef solution codechef
- The first line of the input contains a single integer – the number of test cases. The description of test cases follows.
- The first line of each test case contains a single integer .
- The second line of each test case contains space-separated integers
Careless Chef solution codechef Output Format
- For each test case, print
YESif the provided sequence can be achieved from any sequence of size using the given process. Otherwise, print
You may print each character of
NO in uppercase or lowercase (for example, the strings
YES will be treated identical).
- It is guaranteed that the sum of over all test cases does not exceed
Sample Input 1 Careless Chef solution codechef
3 1 1 1 2 16 2 2022 2001 2 2 4 -2 4
Sample Output 1
YES NO YES
- Test case : The given sequence can be generated using with for .
- Test case : There doesn’t exist any sequence which can generate the given sequence by simulating the given process.
- Test case : The given sequence can be generated using with for and for .