Too Mean CodeChef Solution | CodeChef Problem Solution 2022
You are given an array of length .
You have to partition the elements of the array into some subsequences such that:
- Each element belongs to exactly one subsequence.
- The mean of the mean of subsequences is maximised.
Formally, let denote subsequences of array such that each element belongs to exactly one subsequence .
Let denote the mean of the elements of subsequence . You need to maximise the value .
Print the maximum value. The answer is considered correct if the relative error is less than .
Input Format
- First line will contain , number of test cases. Then the test cases follow.
- First line of each test case consists of a single integer - denoting the length of array .
- Second line of each test case consists of space-separated integers - denoting the array .
Output Format
For each test case, output in a single line, the maximum possible mean of mean of subsequences. The answer is considered correct if the relative error is less than .
Constraints
- Sum of over all test cases does not exceed .
Sample Input 1
3
2
10 20
3
1 2 3
5
50 50 50 50 50
Sample Output 1
15
2.25
50
Explanation
Test Case : We can partition the array in ways - or . In both cases, mean of mean of subsequences comes out to be .
Test Case : The optimal partition is .
- Mean of first subsequence .
- Mean of second subsequence .
Thus, mean of mean of subsequences is .
Test Case : Any partition will yield the mean of mean of subsequences as .
Join Now for Solution:-
No comments:
Post a Comment