CF2060C.Game of Mathletes

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Game of Mathletes

Alice and Bob are playing a game. There are nn (nn is even) integers written on a blackboard, represented by x1,x2,,xnx_1, x_2, \ldots, x_n. There is also a given integer kk and an integer score that is initially 00. The game lasts for n2\frac{n}{2} turns, in which the following events happen sequentially:

  • Alice selects an integer from the blackboard and erases it. Let's call Alice's chosen integer aa.
  • Bob selects an integer from the blackboard and erases it. Let's call Bob's chosen integer bb.
  • If a+b=ka+b=k, add 11 to score.

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?

Input

The first line contains an integer tt (1t1041 \leq t \leq 10^4) — the number of test cases.

The first line of each test case contains two integers nn and kk (2n2105,1k2n2 \leq n \leq 2\cdot 10^5, 1 \leq k \leq 2\cdot n, nn is even).

The second line of each test case contains nn integers x1,x2,,xnx_1,x_2,\ldots,x_n (1xin1 \leq x_i \leq n) — the integers on the blackboard.

It is guaranteed that the sum of nn over all test cases does not exceed 21052\cdot 10^5.

Output

For each test case, output the score if both players play optimally.

Note

In the first test case, one way the game may go is as follows:

  • Alice selects 11 and Bob selects 33. The score increases as 1+3=41+3=4. Now the two integers remaining on the blackboard are 22 and 22.
  • Alice and Bob both select 22. The score increases as 2+2=42+2=4.
  • The game ends as the blackboard now has no integers.

In the third test case, it is impossible for the sum of Alice and Bob's selected integers to be 11, so we answer 00.

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.

Samples

4
4 4
1 2 3 2
8 15
1 2 3 4 5 6 7 8
6 1
1 1 1 1 1 1
16 9
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
2
1
0
4

在线编程 IDE

建议全屏模式获得最佳体验