Under construction

Still being built. Things may change

Trimmed and Corrected Mean

Interview

Time limit1sMemory limit256 MB

Summary
Given N judge scores and an integer K, sort the scores, then output the trimmed mean that drops K from each end and the corrected mean that replaces those extremes with the nearest kept value, both rounded to two decimals.
Level

Easy3 of 10

Topics
Sorting, Prefix sum, Math, Implementation
Solved
No attempts yet

Problem

In sports such as gymnastics or diving, some judges sometimes give an unfairly high score to an athlete they like and an unfairly low score to one they dislike. Taking a plain average of all such scores can therefore be unfair. To prevent this, a trimmed mean and a corrected mean (a Winsorized mean) are used instead.

For example, suppose seven judges gave the following scores.

9.3, 9.5, 9.6, 9.8, 9.1, 5.0, 9.3

Their sum is 61.6, so the plain average is 8.8. This value is dragged down by the single unusually low score of 5.0, and the athlete would feel it is very unfair.

Sorting the scores from smallest to largest gives the following.

5.0, 9.1, 9.3, 9.3, 9.5, 9.6, 9.8

  • Trimmed mean (N,K)(N, K): from the NN sorted scores, discard KK values from each end and average the remaining N−2KN - 2K values. In the example above, the trimmed mean (7,2)(7, 2) drops two values from each end and averages 9.3, 9.3, 9.5, giving 9.37.
  • Corrected mean (N,K)(N, K): instead of discarding the KK values at each end, replace them with the nearest kept value. That is, the KK smallest scores are each replaced by the (K+1)(K+1)-th smallest score and the KK largest scores by the (K+1)(K+1)-th largest score, and then all NN values are averaged. In the example above, the corrected mean (7,2)(7, 2) averages 9.3, 9.3, 9.3, 9.3, 9.5, 9.5, 9.5, giving 9.39.

Given NN scores and the count KK removed (or replaced) at each end, write a program that computes the trimmed mean (N,K)(N, K) and the corrected mean (N,K)(N, K).

Input

The first line contains the total number of scores NN and the number KK removed from each end, separated by a space. NN is a natural number with 3≤N≤1000003 \le N \le 100000, and KK is an integer with 0≤K≤(N/2)−10 \le K \le (N/2) - 1.

Each of the next NN lines contains one judge's score. Each score is a real number between 0.0 and 10.0 inclusive, given to one decimal place.

Output

Print the trimmed mean (N,K)(N, K) on the first line and the corrected mean (N,K)(N, K) on the second line. Round each value half up at the third decimal place and print it to two decimal places.

For example, print 9.667 as 9.67, 5 as 5.00, and 5.5 as 5.50.

Examples1

  1. Example 1

    Input
    7 2
    9.3
    9.5
    9.6
    9.8
    9.1
    5.0
    9.3
    
    Expected output
    9.37
    9.39