CF1920B.Summation Game

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

Summation Game

Alice and Bob are playing a game. They have an array a1,a2,,ana_1, a_2,\ldots,a_n. The game consists of two steps:

  • First, Alice will remove at most kk elements from the array.
  • Second, Bob will multiply at most xx elements of the array by 1-1.

Alice wants to maximize the sum of elements of the array while Bob wants to minimize it. Find the sum of elements of the array after the game if both players play optimally.

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains three integers nn, kk, and xx (1n21051 \leq n \leq 2 \cdot 10^5, 1x,kn1 \leq x,k \leq n) — the number of elements in the array, the limit on the number of elements of the array that Alice can remove, and the limit on the number of elements of the array that Bob can multiply 1-1 to.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2,\ldots, a_n (1ai10001 \leq a_i \leq 1000) — the elements of the array.

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 a single integer — the sum of elements of the array after the game if both players play optimally.

Note

In the first test case, it is optimal for Alice to remove the only element of the array. Then, the sum of elements of the array is 00 after the game is over.

In the second test case, it is optimal for Alice to not remove any elements. Bob will then multiply 44 by 1-1. So the final sum of elements of the array is 3+1+24=23+1+2-4=2.

In the fifth test case, it is optimal for Alice to remove 9,99, 9. Bob will then multiply 5,5,35, 5, 3 by 1-1. So the final sum of elements of the array is 553+3+3+2=5-5-5-3+3+3+2=-5.

Samples

8
1 1 1
1
4 1 1
3 1 2 4
6 6 3
1 4 3 2 5 6
6 6 1
3 7 3 3 32 15
8 5 3
5 5 3 3 3 2 9 9
10 6 4
1 8 2 9 3 3 4 5 3 200
2 2 1
4 3
2 1 2
1 3
0
2
0
3
-5
-9
0
-1

在线编程 IDE

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