| Kotlin Heroes: Episode 12 |
|---|
| Finished |
In a showmatch for a computer game, $$$2n$$$ esports players are set to participate; the rating of the $$$i$$$-th player is $$$a_i$$$. The ratings of all players are distinct.
For each player, the most exciting match will be with the player whose rating is the closest to theirs. Formally, for the $$$i$$$-th player, the best opponent is another player $$$j$$$ such that the absolute difference in their ratings $$$|a_i-a_j|$$$ is minimized among all ways to choose player $$$j$$$. Note that some player can have more than one best opponent.
For example, if there are $$$4$$$ esports players with ratings $$$[3, 7, 5, 12]$$$, then:
The organizers of the showmatch want to pair the participants so that each player is in exactly one pair, and in each pair, the players are best opponents for each other. Determine whether such a pairing exists.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases.
Each test case consists of two lines:
For each test case, if it is possible to pair the participants such that in each pair the participants are best opponents for each other, output YES. Otherwise, output NO.
323 7 5 1223 7 5 823 7 5 9
NO YES YES
In the first example, pairing is impossible. For instance, if we form pairs $$$(1, 3)$$$ and $$$(2, 4)$$$, participant $$$4$$$ will not be the best opponent for participant $$$2$$$.
In the second example, it is possible to pair the participants as $$$(1, 3)$$$ and $$$(2, 4)$$$.
| Name |
|---|


