PDP-26 (2014) - Phase B' Junior High School (ensemble)

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

Rhythmic Gymnastics

Rhythmic Gymnastics is a beautiful but demanding sport. Additionally, in the girls' category, the boundaries between gymnastics and dance are blurred. The Greek Olympic teams are formed from junior high school level and continue even after senior high school^1.

In rhythmic gymnastics, there are N judges who score the performance of each athlete. The final score is the average of the scores given by the N judges. The scores are real numbers between 0 and 10 (with one decimal digit).

For example, for N = 10 judges who gave the following scores: 9.1, 6.2, 7.8, 8.2, 8.4, 5.6, 9.2, 9.3, 8.5, 6.4, the athlete's average score is: 7.87 (always rounded to 2 decimal places).

However, because this scoring method is considered unfair, as it can be negatively or positively influenced by very low or very high scores, two alternative scoring methods have been proposed.

A) Elimination of K high and low scores and calculation of the mean value from the remaining scores. In the above example, if K = 2, we remove the two lowest (5.6 and 6.2) and the two highest (9.2 and 9.3) scores, and the score is the mean value of the remaining ones. In our example, the athlete's score is: 8.07.

B) Replacement of the K lowest and K highest scores with the nearest score and then calculation of the mean of the resulting scores. For K = 2, 5.6 and 6.2 will be replaced by 6.4, and 9.2 and 9.3 will be replaced by 9.1. So, the score will be calculated with the following scores: 9.1, 6.4, 7.8, 8.2, 8.4, 6.4, 9.1, 9.1, 8.5, 6.4, and it is: 7.94.

Problem:

Develop a program in one of the IOI languages that reads the scores of the N judges and returns the calculated score based on the two methods described above.

Input Files:

The input files named ensemble.in are text files with the following structure: The first line contains two integers. The first is the number of judges N\;(3 \le N \le 100.000), and the second is the number of scores K to be replaced by the highest and lowest scores (0 \le K \le |(N-1)/2|). The next N lines contain the scores of the judges B\;(0 \le B \le 10), which are real numbers with one decimal digit.

Output Files:

The output files named ensemble.out are text files with the following structure: They have a single line containing two real numbers (each with exactly two decimal places) separated by a space. The first number is the average score after removing the K lowest and K highest scores, and the second is the average score after replacing the K lowest and K highest scores with the nearest scores.

Examples of Input - Output Files
1st

STDIN (ensemble.in)

10 2
9.1
6.2
7.8
8.2
8.4
5.6
9.2
9.3
8.5
6.4

STDOUT (ensemble.out)

8.07 7.94
2nd

STDIN (ensemble.in)

45 8
0.0
5.6
1.9
8.1
5.9
4.8
3.5
9.0
8.2
7.5
1.7
8.6
7.1
5.1
3.0
0.1
0.9
3.6
1.5
1.7
9.9
4.5
1.2
0.0
0.1
3.8
5.3
5.7
6.0
6.1
1.7
6.6
4.5
3.5
0.6
6.1
7.8
8.0
5.2
3.0
8.8
7.3
9.6
9.3
5.4

STDOUT (ensemble.out)

4.89 4.88

Maximum Execution Time: 1 sec


^1 The National Olympic Rhythmic Gymnastics Team of 2000 (Silver Olympic Medal) was composed of students from the 4th General Lyceum of Heraklion, Athens (E.T.A.D.), who resided in the nearby Olympic facilities from the age of 13!


Comments

There are no comments at the moment.