#K8336. Score Statistics Calculator
Score Statistics Calculator
Score Statistics Calculator
You are given a list of student scores and an integer K. Your task is to compute the following statistics:
- The top K scores (the highest K scores in descending order).
- The bottom K scores (the lowest K scores in ascending order).
- The average score of the remaining scores after excluding the top and bottom K scores. The average is computed using the formula: $$\text{average} = \frac{\sum_{i=K+1}^{N-K}score_i}{N-2K}$$ where N is the total number of scores.
If the total number of scores is less than or equal to 2K, then no scores are considered for the statistics (i.e. both top and bottom lists will be empty and the average is 0.00).
The input is read from the standard input and the output should be written to the standard output in the specified format.
inputFormat
The first line contains two integers N and K, where N is the number of scores and K is the exclusion parameter.
The second line contains N space-separated integers representing the scores.
outputFormat
The output consists of three lines:
- The first line contains the top K scores (in descending order) separated by a single space. If there are no scores, print an empty line.
- The second line contains the bottom K scores (in ascending order) separated by a single space. If there are no scores, print an empty line.
- The third line contains the average of the remaining scores, printed as a floating-point number rounded to two decimal places.
9 2
90 70 85 65 80 95 60 100 75
100 95
60 65
80.00
</p>