AmazonOA #222
Get Minimum Removal
估计简单可在线判题
Delete some products so that at most k distinct categories remain; find the minimum number of products deleted. Every individual item of the same category counts.
输入格式
The first line contains n k; the second line contains the categories. 1≤n,k,category≤100000.
输出格式
Output a single integer, the answer.
样例 1
输入:
4 1
3 3 5 7
输出:
2
样例 2
输入:
2 5
1 2
输出:
0
样例 3
输入:
5 1
1 1 2 2 2
输出:
2
样例说明
The answers are 2, 0 and 2. When k exceeds the actual number of categories, nothing needs to be deleted.