#P6069. 『MdOI R1』Group
『MdOI R1』Group
Description
To make the members of our team more united, we want everyone’s skill level to be as balanced as possible. At this time, someone needs to make some changes to themselves.
Our team has students. The skill value of the -th student is an integer .
We consider the team to be united when the variance of the whole group’s skill values is no more than .
What is the minimum number of students who must change their skill values (they may change them to any real number) so that the team can become united?
To avoid precision errors when reading input, the given is times the real value, and this value is an integer.
If you do not know what variance is, here is the basic concept:
Variance is an indicator that measures how much a set of data fluctuates.
Let the average of a sequence of length be . Then the variance of this sequence is:
Input Format
The first line contains integers , representing the number of students and times the upper limit of the variance.
The second line contains integers , representing each student’s skill value.
Output Format
The first line contains an integer , representing the minimum number of people whose skill values must be changed.
4 32
3 7 -5 -1
1
5 18
1 4 3 6 9
1
6 679
5 83 56 20 54 111
3
Hint
[Sample 1 Explanation]
In this sample, , and the real .
At the beginning, the average of all students’ skill values is , and the variance is:
$$S=\dfrac{1}{4}[(3-1)^2+(7-1)^2+(-5-1)^2+(-1-1)^2]=20$$After changing the 3rd student’s skill value to , the average becomes , and the variance is:
$$S=\dfrac{1}{4}[(3-3)^2+(7-3)^2+(3-3)^2+(-1-3)^2]=8$$Only person’s skill value was changed, which meets the requirement.
[Sample 2 Explanation]
In this sample, , and the real .
At the beginning, the average of all students’ skill values is , and the variance is :
After changing the 5th student’s skill value to , the average becomes , and the variance is .
Only person’s skill value was changed, which meets the requirement.
[Constraints]
| Subtask ID | Points | |
|---|---|---|
| 1 | 15 | |
| 2 | 17 | |
| 3 | 20 | |
| 4 | 7 | |
| 5 | 8 | |
| 6 | 33 |
For all test points, , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号