P19263 [CodeChef] CRISIS
提高+
题目描述

Naruto has recently joined the Ninja Academy for higher education, while filling the admission form he is required to choose minimum $X$ subjects out of a list of $N$ subjects. He is not very interested in studies but wants to get a good overall CPI. However, every subject has a different weightage/credit. The credit (denoted as $C${i}) of a particular course is equal to the position in which it appears in the subject list, i.e, the first course has a credit=1, the second course has a credit=2, and so on.
Naruto knows his capabilities, and so he has come up with the scores ($S$
) he can achieve in every course. He wants to maximise his CPI, which can be calculated as the weighted mean of all the subjects taken, denoted as
Sum(C_{i}*S_{i})/Sum(C_{i}) for all i s.t Naruto has taken up course i

------ Input: ------

First line will contain $T$, number of testcases. Then the testcases follow.
First line of every test case contains two integers, $N$ and $X$
Next line of the test case contains $N$ space separated integers S_{i}, denoting the score he can get in every subject

------ Output: ------
For each testcase, output in a single line the maximum cpi he can get after choosing the subjects. Your output will be considered correct if it has an absolute error of less than 10^{-6}.

------ Constraints ------
$1 ≤ T ≤ 10$
$1 ≤ N ≤ 1000$
$1 ≤ X ≤ N$
$1 ≤ S$_{i}$ ≤ 10000$

------ Sample Input: ------
1
5 2
50 40 30 20 10

------ Sample Output: ------
43.3333333333

------ Explanation: ------
He can achieve the max credit by picking the first two subjects, which produces a CPI of (50 * 1+40 * 2)/(1+2) = 43.333333333

输入格式

见题面

输出格式

见题面

样例输入
1 5 2 50 40 30 20 10
样例输出
43.3333333333