#P10335. [UESTCPC 2024] 取数游戏
[UESTCPC 2024] 取数游戏
Problem Description
There is a sequence of length . The weight of the -th number is . Two players, A and B, are playing a game. They will take turns performing operations on the sequence. Each player has two choices each turn:
- Delete any two numbers from the sequence, and add a new number with weight into the sequence. When there is only one number in the sequence, this operation cannot be performed.
- Take away one number from the sequence, add up the weights of all remaining numbers and give the total to the opponent, then end the game.
If A ends up with a larger total weight, then A wins; otherwise, B wins.
A moves first. Determine whether A has a winning strategy. It is guaranteed that the sum of is odd.
Input Format
This problem contains multiple test cases.
The first line contains an integer , denoting the number of test cases.
For each test case, the input format is as follows.
The first line contains an integer , denoting the initial length of the sequence.
The second line contains integers , denoting the initial sequence.
It is guaranteed that and is odd.
Output Format
For each test case, if A has a winning strategy, output YES; otherwise output NO.
3
3
3 6 4
2
1 2
3
2 5 6
NO
YES
NO
Hint
The explanation for Sample 1 is as follows:
- If A chooses the number with weight , then the weight B can get is .
- If A chooses the number with weight , then the weight B can get is .
- If A chooses the number with weight , then the weight B can get is .
- If A chooses to merge weights , the sequence becomes . If B chooses the number with weight , then the weight A can get is .
- If A chooses to merge weights , the sequence becomes . If B chooses the number with weight , then the weight A can get is .
- If A chooses to merge weights , the sequence becomes . If B chooses the number with weight , then the weight A can get is .
In all cases, B can obtain a higher total weight by playing optimally, so A cannot win.
The explanation for Sample 2 is as follows:
If A chooses the number with weight , then the weight B can get is .
Therefore, A has a winning strategy.
Translated by ChatGPT 5