#P6069. Balanced Team Variance Minimization
Balanced Team Variance Minimization
Balanced Team Variance Minimization
We are given a team of n members, and each member has an integer ability value ai for i = 1, 2, \dots, n. The team is considered united if the variance of the ability values does not exceed a given threshold. In this problem, the variance of a sequence a1\dots n with average p is defined as
However, to avoid precision issues during input, the value m
provided in the input is actually the allowed sum of squared deviations, i.e. m = n \times S
. That is, the united condition becomes
You are allowed to change the ability values of some team members to any real number. By doing so, you can set the changed members’ abilities arbitrarily. In the optimal strategy, one can choose a subset of members to keep their original values and set the abilities of the remaining members exactly equal to the average of the kept ones, so that these modified members contribute zero to the variance. Hence, if you maintain a subset S of indices and let \overline{a} be the average of the selected original values, then the united condition becomes
Your task is to determine the minimum number of members you have to change so that there exists a choice of kept members satisfying the above inequality. Equivalently, if the largest subset of indices (whose original values have sum of squared deviations at most m
) has size k, then the answer is n - k
.
inputFormat
The first line contains two integers n
and m
(as described above). The second line contains n
integers, representing the ability values a1, a2, \dots, an
.
outputFormat
Output one integer — the minimum number of team members whose ability values must be changed in order for the team to be united.
sample
5 10
1 2 3 4 5
0