#C1251. Average of Top K Scores
Average of Top K Scores
Average of Top K Scores
You are given T test cases. For each test case, you are provided with an integer N which represents the number of scores and an integer K indicating the number of highest scores to consider. Then, a sequence of N scores is given. Your task is to calculate the average of the top K scores for each test case.
The average must be computed using the following formula:
\(\text{average} = \frac{\sum_{i=1}^{K} s_i}{K}\)
where \( s_i \) are the top K scores. Round the answer to two decimal places.
Print the answer for each test case on a new line.
inputFormat
The input begins with an integer T, the number of test cases. Each test case consists of two lines:
- The first line contains two integers N and K, separated by a space.
- The second line contains N space-separated integers representing the scores.
outputFormat
For each test case, print a single line containing the average of the top K scores, rounded to two decimal places.
## sample4
5 3
50 90 80 70 60
2 2
30 45
4 2
100 100 100 100
6 1
20 40 60 80 100 90
80.00
37.50
100.00
100.00
</p>