Codeforces Round 998 (Div. 3) |
---|
Finished |
Alice and Bob are playing a game. There are $$$n$$$ ($$$n$$$ is even) integers written on a blackboard, represented by $$$x_1, x_2, \ldots, x_n$$$. There is also a given integer $$$k$$$ and an integer score that is initially $$$0$$$. The game lasts for $$$\frac{n}{2}$$$ turns, in which the following events happen sequentially:
Alice is playing to minimize the score while Bob is playing to maximize the score. Assuming both players use optimal strategies, what is the score after the game ends?
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \leq n \leq 2\cdot 10^5, 1 \leq k \leq 2\cdot n$$$, $$$n$$$ is even).
The second line of each test case contains $$$n$$$ integers $$$x_1,x_2,\ldots,x_n$$$ ($$$1 \leq x_i \leq n$$$) — the integers on the blackboard.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, output the score if both players play optimally.
44 41 2 3 28 151 2 3 4 5 6 7 86 11 1 1 1 1 116 93 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
2 1 0 4
In the first test case, one way the game may go is as follows:
In the third test case, it is impossible for the sum of Alice and Bob's selected integers to be $$$1$$$, so we answer $$$0$$$.
Note that this is just an example of how the game may proceed for demonstration purposes. This may not be Alice or Bob's most optimal strategies.
Name |
---|