IBMOA #19
Equalize Team Size
Estimated MediumJudge-ready
Topics (AI-labelled)HashingIn-place Arrays
Choose at most k teams and reduce their sizes; sizes cannot be increased, and no new team can be split off. Find the maximum number of teams that end up with the same size.
Input
The first line contains n k, and the second line contains the team sizes. 1≤n≤200000, sizes are 1..10^9, 0≤k≤10^9.
Output
Output one integer, the answer.
Example 1
Input:
5 2
1 2 2 3 4
Output:
4
Example 2
Input:
3 0
3 3 1
Output:
2
Example 3
Input:
3 99
1 2 3
Output:
3
Example notes
The examples give 4, 2 and 3 respectively.
Editorial
Loading solution…