QOJ.ac

QOJ

Süre Sınırı: 1 s Bellek Sınırı: 128 MB

#23525. Trimmed Mean

İstatistikler

In sports such as gymnastics and diving, some judges have sometimes given high scores to athletes they like and low scores to those they dislike. Thus, awarding an athlete the average of all judges’ scores can be unfair. To prevent this, a trimmed mean or a winsorized mean is used. For example, suppose seven judges give the scores $9.3$, $9.5$, $9.6$, $9.8$, $9.1$, $5.0$, $9.3$. Their sum is $61.6$, so the average is $8.8$. This average results from one judge giving the very low score $5.0$ compared with the others, and the athlete would feel very unfairly treated. Sorting the scores in ascending order gives $5.0$, $9.1$, $9.3$, $9.3$, $9.5$, $9.6$, $9.8$. The trimmed mean $(7,2)$ removes two scores from each end of these seven sorted scores and averages the remaining $9.3$, $9.3$, $9.5$, obtaining $9.37$ (rounded at the third decimal place). The winsorized mean $(7,2)$ replaces the two scores at each end with the nearest remaining score, then averages $9.3$, $9.3$, $9.3$, $9.3$, $9.5$, $9.5$, $9.5$, obtaining $9.39$ (rounded at the third decimal place). Given $N$ scores and the number $K$ removed from each end, write a program to calculate the trimmed mean $(N,K)$ and winsorized mean $(N,K)$.

Input

The first line contains the total number of scores $N$ and the number of scores to remove $K$, separated by a space. $N$ is a positive integer from $3$ to $100,000$. $K$ ranges from $0$ to $N/2-1$. Each of the next $N$ lines contains one judge’s score. Each score is a real number from $0$ to $10$ given to one decimal place.

Output

Print the trimmed mean $(N,K)$ on the first line and the winsorized mean $(N,K)$ on the second line, each rounded at the third decimal place and printed to two decimal places. For example, print $9.667$ as $9.67$, $5$ as $5.00$, and $5.5$ as $5.50$.

Examples

Input 1

7 2
9.3
9.5
9.6
9.8
9.1
5.0
9.3

Output 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.