#P11309. 纷飞的樱花雨
纷飞的樱花雨
Description
Little adores watching cherry blossoms. During the falling of cherry blossoms, the beauty value of the -th falling blossom is .
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 of length , perform exactly swaps to maximize .
Input Format
Multiple test cases.
The first line contains , the number of test cases.For each test case:
First line contains two integers and .
Next line contains n space-separated integers representing the initial values of .
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: ,,,,。
| Test Point ID | ||
|---|---|---|
| - | ||
| - | ||
| - |
京公网安备 11011102002149号