#abc291b. B - Trimmed Mean
B - Trimmed Mean
Score : points
问题描述
高桥正在参加一场体操比赛。
在比赛中,每位裁判会为高桥的表现打分,他的得分计算方法如下:
- 取消给出最高分的 位裁判的评分。
- 取消给出最低分的 位裁判的评分。
- 高桥的得分定义为剩余 位裁判评分的平均值。
更正式地,通过以下步骤对包含裁判评分的多重集合 ()进行操作来得到高桥的得分:
- 重复以下操作 次:选择并移除当前最大元素(如果有多个最大元素,则从中选择一个)。
- 重复以下操作 次:选择并移除当前最小元素(如果有多个最小元素,则从中选择一个)。
- 高桥的得分由剩余的 个元素的平均值得出。
第 位()裁判给高桥的表现打分为 分。请计算高桥的得分。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi is participating in a gymnastic competition.
In the competition, each of judges grades Takahashi's performance, and his score is determined as follows:
- Invalidate the grades given by the judges who gave the highest grades.
- Invalidate the grades given by the judges who gave the lowest grades.
- Takahashi's score is defined as the average of the remaining judges' grades.
More formally, Takahashi's score is obtained by performing the following procedure on the multiset of the judges' grades ():
- Repeat the following operation times: choose the maximum element (if there are multiple such elements, choose one of them) and remove it from .
- Repeat the following operation times: choose the minimum element (if there are multiple such elements, choose one of them) and remove it from .
- Takahashi's score is defined as the average of the elements remaining in .
The -th judge's grade for Takahashi's performance was points. Find Takahashi's score.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print Takahashi's score.
Your answer will be considered correct if the absolute or relative error from the true value is at most .
Sample Input 1
1
10 100 20 50 30
Sample Output 1
33.333333333333336
Since , the grade given by one judge who gave the highest grade, and one with the lowest, are invalidated.
The -nd judge gave the highest grade ( points), which is invalidated.
Additionally, the -st judge gave the lowest grade ( points), which is also invalidated.
Thus, the average is .
Note that the output will be considered correct if the absolute or relative error from the true value is at most .
Sample Input 2
2
3 3 3 4 5 6 7 8 99 100
Sample Output 2
5.500000000000000
Since , the grades given by the two judges who gave the highest grades, and two with the lowest, are invalidated.
The -th and -th judges gave the highest grades ( and points, respectively), which are invalidated.
Three judges, the -st, -nd, and -rd, gave the lowest grade ( points), so two of them are invalidated.
Thus, the average is .
Note that the choice of the two invalidated judges from the three with the lowest grades does not affect the answer.
update @ 2024/3/10 12:08:21