Figure Skating Judging
시간 제한2초메모리 제한2048 MB
n개의 점수 중 k개를 골라, 고른 점수들의 평균에서 각 점수가 벗어난 제곱 편차의 합을 최소로 만든다.
문제
Anissa has just finished her figure skating routine and is anxiously awaiting her scores. The way scoring works at this specific event is a little peculiar - each figure skater is evaluated by several judges and the scores are averaged to give a final score.
Jolie is managing the software used to compile the scores and notices that a hacker has gotten in and inserted many fake evaluations. She knows exactly how many scores she should expect, so she will manually invalidate evaluations until the number of evaluations matches the number of judges she knows actually submitted evaluations.
The problem is, Jolie doesn’t know which evaluation to invalidate. She decides to use the following metric for assessing the badness of a collection of scores after invalidating enough to get the number of evaluations to match the number of judges:
- Compute the arithmetic mean of all the evaluations from the chosen collection.
- Compute the squared deviation of each evaluation in the chosen collection to the given arithmetic mean. That is, if the mean is and a given evaluation is , the squared deviation is .
- Compute the sum of all squared deviations from step 2. This sum is the badness.
Compute the minimum badness over all possible collections of scores that can be obtained.
입력
The first line of input contains two integers, and , where is the total number of evaluations and is the expected number of evaluations.
Each of the next lines contains a single integer . These are the evaluations.
출력
Output a single number, which is the minimum badness over all possible collections of scores that can be obtained. Answer is correct if it is within absolute or relative error of .