#Q1399A. Remove Smallest
Remove Smallest
Remove Smallest
题面翻译
给你一个 个整数的数列,你可以每次选择满足一下条件的两个位置 :
然后删除 中较小的那一个。
问能否通过若干次操作将数列删除到只剩一个数。
题目描述
You are given the array consisting of positive (greater than zero) integers.
In one move, you can choose two indices and ( ) such that the absolute difference between and is no more than one ( ) and remove the smallest of these two elements. If two elements are equal, you can remove any of them (but exactly one).
Your task is to find if it is possible to obtain the array consisting of only one element using several (possibly, zero) such moves or not.
You have to answer independent test cases.
输入格式
The first line of the input contains one integer ( ) — the number of test cases. Then test cases follow.
The first line of the test case contains one integer ( ) — the length of . The second line of the test case contains integers ( ), where is the -th element of .
输出格式
For each test case, print the answer: "YES" if it is possible to obtain the array consisting of only one element using several (possibly, zero) moves described in the problem statement, or "NO" otherwise.
样例 #1
样例输入 #1
5
3
1 2 2
4
5 5 5 5
3
1 2 4
4
1 3 4 4
1
100
样例输出 #1
YES
YES
NO
NO
YES
提示
In the first test case of the example, we can perform the following sequence of moves:
- choose and and remove (so becomes );
- choose and and remove (so becomes ).
In the second test case of the example, we can choose any possible and any move and it doesn't matter which element we remove.
In the third test case of the example, there is no way to get rid of and .