QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 128 MB

#23525. 截尾平均數

統計

在體操、跳水等比賽中,曾經常出現一些裁判給自己喜歡的選手打高分、給不喜歡的選手打低分的情況。因此,如果把裁判評分的平均值作為選手得分,就可能不公平。為防止這種情況,會使用截尾平均數或縮尾平均數。例如,七名裁判給出的分數為 $9.3$、$9.5$、$9.6$、$9.8$、$9.1$、$5.0$、$9.3$。總和為 $61.6$,因此平均值為 $8.8$。這個平均值是由於一名裁判給出了比其他裁判低得多的 $5.0$ 分而產生的,選手會覺得十分不公平。將上述分數從小到大排序,得到 $5.0$、$9.1$、$9.3$、$9.3$、$9.5$、$9.6$、$9.8$。此時,截尾平均數 $(7,2)$ 是從這七個排好序的分數兩端各去掉兩個後,剩下的 $9.3$、$9.3$、$9.5$ 的平均值,即 $9.37$(在小數點後第三位四捨五入)。縮尾平均數 $(7,2)$ 則將兩端各兩個分數替換為剩餘分數中離它最近的分數,得到 $9.3$、$9.3$、$9.3$、$9.3$、$9.5$、$9.5$、$9.5$,取其平均值得到 $9.39$(在小數點後第三位四捨五入)。給定 $N$ 個分數及兩端各去掉的數量 $K$,請編寫程式,計算截尾平均數 $(N,K)$ 和縮尾平均數 $(N,K)$。

輸入格式

第一行給出總評分數量 $N$ 和去掉的評分數量 $K$,以空格分隔。$N$ 是 $3$ 到 $100,000$ 的正整數。$K$ 的範圍為 $0$ 到 $N/2-1$。接下來 $N$ 行,每行給出一名裁判的分數。分數是 $0$ 到 $10$ 的實數,給到小數點後一位。

輸出格式

第一行輸出截尾平均數 $(N,K)$,第二行輸出縮尾平均數 $(N,K)$,均在小數點後第三位四捨五入,保留兩位小數。例如,結果為 $9.667$ 時輸出 $9.67$,為 $5$ 時輸出 $5.00$,為 $5.5$ 時輸出 $5.50$。

範例

輸入格式 1

7 2
9.3
9.5
9.6
9.8
9.1
5.0
9.3

輸出格式 1

9.37
9.39

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.