B. Tournament
You are given an array of integers . A tournament is held with players. Player has strength .
While more than players remain,
- Two remaining players are chosen at random;
- Then the chosen player with the lower strength is eliminated. If the chosen players have the same strength, one is eliminated at random.
Given integers and (), determine if there is any way for player to be one of the last remaining players.
The first line contains an integer () — the number of test cases.
The first line of each test case contains three integers , , and (, ).
The second line of each test case contains integers, ().
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, output on a single line "YES" if player can be one of the last remaining players, and "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
35 2 33 2 4 4 15 4 15 3 4 5 26 1 11 2 3 4 5 6
YES YES NO
In the first sample, suppose that players and are chosen. Then player defeats player . Now, the remaining player strengths are
| 3 | 2 | 4 | 4 |
| 3 | 2 | 4 |
In the third sample, it can be shown that there is no way for player to be the last player remaining.
Tournament problem solution by Java,
Tournament problem solution by Python