#K40227. Calculate Final Scores
Calculate Final Scores
Calculate Final Scores
In this problem, you are given multiple test cases. Each test case contains a list of scores. Your task is to calculate the final score for each test case according to the following rule:
If the number of scores ( n ) is at least 3, then the final score is the average of the top three highest scores, i.e., [ \text{Final Score} = \frac{s_1 + s_2 + s_3}{3} ] where ( s_1, s_2, s_3 ) are the three highest scores in the test case. Otherwise, if ( n < 3 ), the final score is the average of all scores.
The answer must be printed with exactly six decimal places. This problem tests your ability to perform sorting and arithmetic operations with precision.
inputFormat
The input is read from standard input (stdin). The first line contains an integer ( T ) denoting the number of test cases. For each test case, the first line contains an integer ( N ) indicating the number of scores, followed by a line containing ( N ) space-separated integers representing the scores.
outputFormat
For each test case, output a single line with the final score formatted to six decimal places. The output is written to standard output (stdout).## sample
2
5
50 95 85 75 90
2
45 70
90.000000
57.500000
</p>