Коварные женские уловки

Женские козни

До сих пор Артём остаётся холостяком. Хотя намерения жениться у него были самые серьёзные, вот только логику своей невесты он так и не постиг.

Когда он сделал Алине предложение, они встречались уже почти год. Страсти поутихли, и Артём наконец осознал, что она — та самая, с кем хочется идти по жизни, видеть её каждый день, слышать её голос.

— Алина, буд# [USACO07JAN]Cow School G

## 题目描述

Bessy is going to school and doing well. She has taken N (1 ≤ N ≤ 5000 — except one case where 1 ≤ N ≤ 50,000) tests and recorded the scores (Ti points on test i), and now has to report to her parents the difference between her current average and her least successful test. Bessy must choose which D (1 ≤ D ≤ N) tests to drop from the reported set of tests, in order to maximize the difference.

Bessy has noted that in all cases she has taken at least two tests, and that the current average is never lower than the least score over those tests.

Help Bessiy determine the maximum possible difference between the average of her tests after dropping D tests and the lowest remaining test score.

Bessy要去学校上学了,在学校的表现也不错。她已经参加了N次考试(1≤N≤5000,但有一个测试点是1≤N≤50000),并且记录了每次测试的得分(第i次测试得了Ti分),现在她必须向父母汇报她目前的平均分与最不成功的考试的分数之间的差值。Bessy必须从报告中选择放弃D(1≤D≤N)次测试,以最大化这个差值。

Bessy注意到,在所有情况下她至少参加了两次考试,并且目前的平均分永远不会低于这些测试的最低分数。

请你帮助Bessy确定,在放弃D次测试之后,剩余测试的平均分与最低分之间可能的最大差值。

## 输入格式

\* Line 1: Two space separated integers: N and D

\* Lines 2..N+1: Line i+1 contains a single integer: Ti

## 输出格式

\* Line 1: A single real number (rounded to 3 decimal places) which is the maximal difference possible between the average score after dropping D tests and the lowest score of the remaining tests.

## 样例 #1

### 样例输入 #1
“`
5 1
1
2
3
4
5
“`

### 样例输出 #1

“`
2.000
“`

## 提示

INPUT DETAILS:

Five tests with scores 1, 2, 3, 4, 5. Bessy must drop one test.

OUTPUT DETAILS:

The best solution is to drop the 1, getting an average of (2+3+4+5)/4 = 3.5 and a low of 2 (from test 2). The difference is 1.5. The same difference comes from dropping tests 2 or 3. Dropping test 4 gives an average of 2.75 and a low of 1 for a difference of 1.75. Dropping test 5 gives a difference of 1. Dropping test 1 gives the maximal difference, as shown.

Rate article
Коварные женские уловки