创建于 2026/07/17 · 更新于 2026/07/17
You were gifted a set containing many different integers. As you find large sets too intimidating, you want to make it smaller. In order to achieve this, you are allowed to apply the following operations to it:
Note that, as this is a set, when after an operation two elements would have the same value, only one of them stays in the set, decreasing its size by one.
The first line contains two integers (), the initial size of the set and the size you want to reach.
The next line contains distinct integers (), the numbers in the initial set.
Output the minimal number of operations required to reduce the size of the set to .
5 4
8 4 6 1 10
2
4 2
1 8 3 9
3
4 1
11 4 12 7
8
3 3
1 5 4
0