102911: [Atcoder]ABC291 B - Trimmed Mean

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:11 Solved:0

Description

Score : $200$ points

Problem Statement

Takahashi is participating in a gymnastic competition.
In the competition, each of $5N$ judges grades Takahashi's performance, and his score is determined as follows:

  • Invalidate the grades given by the $N$ judges who gave the highest grades.
  • Invalidate the grades given by the $N$ judges who gave the lowest grades.
  • Takahashi's score is defined as the average of the remaining $3N$ judges' grades.

More formally, Takahashi's score is obtained by performing the following procedure on the multiset of the judges' grades $S$ ($|S|=5N$):

  • Repeat the following operation $N$ times: choose the maximum element (if there are multiple such elements, choose one of them) and remove it from $S$.
  • Repeat the following operation $N$ times: choose the minimum element (if there are multiple such elements, choose one of them) and remove it from $S$.
  • Takahashi's score is defined as the average of the $3N$ elements remaining in $S$.

The $i$-th $(1\leq i\leq 5N)$ judge's grade for Takahashi's performance was $X_i$ points. Find Takahashi's score.

Constraints

  • $1\leq N\leq 100$
  • $0\leq X_i\leq 100$
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

$N$
$X_1$ $X_2$ $\ldots$ $X_{5N}$

Output

Print Takahashi's score.
Your answer will be considered correct if the absolute or relative error from the true value is at most $10^{-5}$.


Sample Input 1

1
10 100 20 50 30

Sample Output 1

33.333333333333336

Since $N=1$, the grade given by one judge who gave the highest grade, and one with the lowest, are invalidated.
The $2$-nd judge gave the highest grade ($100$ points), which is invalidated.
Additionally, the $1$-st judge gave the lowest grade ($10$ points), which is also invalidated.
Thus, the average is $\displaystyle\frac{20+50+30}{3}=33.333\cdots$.

Note that the output will be considered correct if the absolute or relative error from the true value is at most $10^{-5}$.


Sample Input 2

2
3 3 3 4 5 6 7 8 99 100

Sample Output 2

5.500000000000000

Since $N=2$, the grades given by the two judges who gave the highest grades, and two with the lowest, are invalidated.
The $10$-th and $9$-th judges gave the highest grades ($100$ and $99$ points, respectively), which are invalidated.
Three judges, the $1$-st, $2$-nd, and $3$-rd, gave the lowest grade ($3$ points), so two of them are invalidated.
Thus, the average is $\displaystyle\frac{3+4+5+6+7+8}{6}=5.5$.

Note that the choice of the two invalidated judges from the three with the lowest grades does not affect the answer.

Input

题意翻译

# [ABC291B] 修剪均值 ## 题目描述 [problemUrl]: https://atcoder.jp/contests/abc291/tasks/abc291_b 高橋君正参加体操比赛。 比赛中,$ 5N $ 位评委会各自对高橋君的表演打分,根据这些分数确定高橋君的得分如下: - 从打分最高的人开始,取消 $ N $ 人的分数。 - 从打分最低的人开始,取消 $ N $ 人的分数。 - 将剩余的 $ 3N $ 人的平均分作为高橋君的得分。 更精确地说,以评委打出的分数的多重集合 $ S $ ($ |S|=5N $) 为基础,根据以下操作得到的就是高橋君的得分: - 重复 $ N $ 次「从 $ S $ 中选择最大的元素(若有多个,取其中之一)并将其移出 $ S $」的操作。 - 重复 $ N $ 次「从 $ S $ 中选择最小的元素(若有多个,取其中之一)并将其移出 $ S $」的操作。 - 将 $ S $ 中剩余的 $ 3N $ 个元素的平均数作为高橋君的得分。 高橋君的表演得到的 $ i $ 位($ 1\leq\ i\leq\ 5N $)评委的分数是 $ X_i $ 分。请计算高橋君的得分。 ## 输入格式 输入通过標準輸入给出,形式为: > $ N $ $ X_1 $ $ X_2 $ $ \ldots $ $ X_{5N} $ ## 输出格式 输出高橋君的得分。 注意,只要真值与输出值的绝对误差或相对误差不超过 $ 10^{-5} $,即被视为正确答案。 ## 样例 #1 ### 样例输入 #1 ``` 1 10 100 20 50 30 ``` ### 样例输出 #1 ``` 33.333333333333336 ``` ## 样例 #2 ### 样例输入 #2 ``` 2 3 3 3 4 5 6 7 8 99 100 ``` ### 样例输出 #2 ``` 5.500000000000000 ``` ## 提示 ### 制約 - $ 1\leq\ N\leq\ 100 $ - $ 0\leq\ X_i\leq\ 100 $ - 输入均为整数 ### 样例解释 #1 由于 $ N=1 $,因此取消分数最高和最低的人各 $ 1 $ 人。最高分是第 $ 2 $ 人 ($ 100 $ 分),最低分是第 $ 1 $ 人 ($ 10 $ 分),所以要取消它们。因此,最终的平均分为 $ \displaystyle\frac{20+50+30}{3}=33.333\cdots $。请注意,只要真值与输出值的绝对误差或相对误差不超过 $ 10^{-5} $,即被视为正确答案。 ### 样例解释 #2 由于 $ N=2 $,因此取消分数最高和最低的人各 $ 2 $ 人。最高分是第 $ 10 $ 人 ($ 100 $ 分) 和第 $ 9 $ 人 ($ 99 $ 分),最低分是第 $ 1 $、$ 2 $、$ 3 $ 人 ($ 3 $ 分),所以要取消其中的 $ 2 $ 人。因此,答案是 $ \displaystyle\frac{3+4+5+6+7+8}{6}=5.5 $。注意,最低分的 $ 3 $ 人中哪 $ 2 $ 人被取消并不影响答案。

Output

分数:$200$分

问题描述

高桥正在参加一个体操比赛。

在这个比赛中,$5N$名评委对高桥的表现进行评分,他的分数是这样确定的:

  • 取消给分最高的$N$名评委的评分。
  • 取消给分最低的$N$名评委的评分。
  • 高桥的分数定义为剩余$3N$名评委评分的平均值。

更正式地说,高桥的分数是通过以下过程获得的:对评委评分集合$S$($|S|=5N$)进行以下操作:

  • 重复以下操作$N$次:选择最大的元素(如果有多个这样的元素,选择其中一个)并从$S$中删除它。
  • 重复以下操作$N$次:选择最小的元素(如果有多个这样的元素,选择其中一个)并从$S$中删除它。
  • 高桥的分数定义为$S$中剩余$3N$个元素的平均值。

第$i$个($1\leq i\leq 5N$)评委给高桥的表演打分为$X_i$分。 找出高桥的分数。

约束条件

  • $1\leq N\leq 100$
  • $0\leq X_i\leq 100$
  • 输入中的所有值都是整数。

输入

输入是通过标准输入以以下格式给出的:

$N$
$X_1$ $X_2$ $\ldots$ $X_{5N}$

输出

打印高桥的分数。
如果与真实值的绝对误差或相对误差不超过$10^{-5}$,则答案将被认为是正确的。


样例输入1

1
10 100 20 50 30

样例输出1

33.333333333333336

由于$N=1$,给分最高的评委的评分和给分最低的评委的评分将被取消。
第$2$个评委给出的分数最高($100$分),被取消。
此外,第$1$个评委给出的分数最低($10$分),也被取消。
因此,平均分为$\displaystyle\frac{20+50+30}{3}=33.333\cdots$。

注意,如果与真实值的绝对误差或相对误差不超过$10^{-5}$,则输出将被认为是正确的。


样例输入2

2
3 3 3 4 5 6 7 8 99 100

样例输出2

5.500000000000000

由于$N=2$,给分最高的$2$名评委的评分和给分最低的$2$名评委的评分将被取消。
第$10$名和第$9$名评委给出的分数最高(分别是$100$分和$99$分),被取消。
第$1$名、第$2$名和第$3$名评委给出的分数最低(都是$3$分),其中的$2$名将被取消。
因此,平均分为$\displaystyle\frac{3+4+5+6+7+8}{6}=5.5$。

注意,从最低$3$名评分的评委中选择取消$2$名评分的评委的选择不会影响答案。

HINT

5n个数,去掉n个最高分和n个最低分,求平均值?

加入题单

算法标签: