#P7458. [2017年杭电多校]Kanade's sum
[2017年杭电多校]Kanade's sum
Kanade's sum
Problem Description
Give you an array of length . Let be the k-th largest element of . Specially , if . Give you , you need to calculate There are T test cases.
Input
There is only one integer T on first line. For each test case,there are only two integers , on first line,and the second line consists of integers which means the array
Output
For each test case,output an integer, which means the answer.
Sample Input
1
5 2
1 2 3 4 5
Sample Output
30
Source
2017 Multi-University Training Contest - Team 3