#K34217. Trimmed Average Score Calculator
Trimmed Average Score Calculator
Trimmed Average Score Calculator
Given multiple test cases, each consisting of several subjects, compute the trimmed average score for each subject. For a subject with n scores, if n \lt 3 then the score is defined as -1. Otherwise, remove the lowest and highest scores and calculate the average of the remaining scores.
The trimmed average for a subject with scores sorted in ascending order \( a_1, a_2, \ldots, a_n \) is computed as:
\( \text{avg} = \frac{\sum_{i=2}^{n-1} a_i}{n-2} \)
Process all test cases from the input and print the result for each subject on a new line.
inputFormat
The input is read from standard input (stdin) and is structured as follows:
- An integer \( T \) representing the number of test cases.
- For each test case:
- An integer \( S \) representing the number of subjects.
- For each subject:
- An integer \( N \) representing the number of scores.
- A line containing \( N \) space-separated integers representing the scores.
outputFormat
For each subject in every test case, output a single line. If the subject has fewer than three scores, output -1. Otherwise, output the trimmed average score formatted to exactly two decimal places.
Output is written to standard output (stdout).
## sample2
2
5
50 60 70 80 90
3
80 90 100
1
2
70 75
70.00
90.00
-1
</p>