#P11309. 纷飞的樱花雨

纷飞的樱花雨

Description

Little ζ \zeta adores watching cherry blossoms. During the falling of n n cherry blossoms, the beauty value of the i i -th falling blossom is ai a_i .

After each blossom falls, the total viewing score increases by the maximum beauty value among all fallen blossoms (including the current one and all previous ones). You can swap the falling order of two blossoms exactly k times (you cannot swap a blossom with itself, but you can swap the same pair multiple times).

Your task is to maximize the total viewing score.

Formally, given an array a a of length n n , perform exactly k k swaps to maximize i=1nmaxj=1iaj \sum_{i=1}^n\max_{j=1}^ia_j .

Input Format

Multiple test cases.

The first line contains T T , the number of test cases.For each test case:

First line contains two integers n n and k k .

Next line contains n space-separated integers representing the initial values of ai a_i .

Output Format

For each test case, output one line containing a single integer - the maximum possible total viewing score.

3
3 0
9 8 2
2 1
10 11
5 10
1 2 3 4 5
27
22
25
5
5 0
100 101 102 103 104
5 1
20 40 50 70 10
2 103
30 20
7 2
1 2 3 4 5 6 7
2 10
1 1
510
350
50
49
2

Hint

「Sample 1 Explanation」

For the second test case, you can swap 10 and 11, making the total viewing score 11 + 11 = 22.

「Data Constraints」

For 100% of test cases: 1T500 1 \le T \le 500 2n105 2 \le n \le 10^5 0k109 0 \le k \le 10^9 n106 \sum n \le 10^6 1ai109 1 \le a_i \le 10^9

Test Point ID n n k k
1 1 50 \le 50 =0 =0
2 2 -
34 3 \sim 4 50 \le 50 =1 =1
57 5 \sim 7 -
810 8 \sim 10 -