P17536 [JAG 2026 Summer Camp #1] Group Strength
Description
There are $N$ students in a class. Student $i$ has an ability value of $A_i$.
The teacher will divide the students into exactly $K$ groups. Each student must belong to exactly one group, and each group must contain at least one student.
The strength of a group is defined as the average of the ability values of the students in that group. The teacher wants to maximize the sum of the strengths of the $K$ groups.
Find the maximum possible sum of the strengths of the $K$ groups.
Input Format
The input consists of multiple test cases in the following format.
```text
T
case_1
case_2
...
case_T
```
Each test case is given in the following format.
```text
N K
A_1 A_2 ... A_N
```
The first line contains an integer $T$ ($1\le T\le 2\times 10^5$), the number of test cases.
The first line of each test case contains two integers $N$ and $K$ ($1\le K\le N\le 2\times 10^5$), the number of students and the number of groups, respectively.
The second line of each test case contains $N$ integers $A_1,A_2,\ldots,A_N$ ($1\le A_i\le 10^9$), where $A_i$ represents the ability value of student $i$.
The sum of $N$ over all test cases does not exceed $2\times 10^5$.
Output Format
For each test case, print the maximum possible sum of the strengths of the $K$ groups on a separate line. Your answer will be considered correct if its absolute or relative error does not exceed $10^{-7}$.