#C5105. Guaranteed Draw Game
Guaranteed Draw Game
Guaranteed Draw Game
You are given several test cases. In each test case, you have a bag of fruits. The bag contains n fruits, and each fruit is represented by an integer indicating its type. Two players (you and Alex) take turns picking fruits optimally. You want to know if you can guarantee at least a draw.
It can be proven that you can guarantee a draw if and only if the number of distinct fruit types is at least
$$\lceil \frac{n}{2} \rceil$$.
For each test case, output YES
if this condition holds, otherwise output NO
.
inputFormat
The input is given from stdin and has the following format:
- The first line contains an integer T, the number of test cases.
- For each test case:
- The first line contains an integer n, the number of fruits.
- The second line contains n space-separated integers indicating the types of the fruits.
outputFormat
For each test case, output a single line to stdout containing either YES
or NO
according to whether you can guarantee at least a draw.
3
6
1 2 3 4 5 6
5
1 1 1 1 1
4
1 2 2 1
YES
NO
YES
</p>