#K68262. Minimum Additional Ingredients
Minimum Additional Ingredients
Minimum Additional Ingredients
You are given n ingredients, each with a specific freshness level. Your task is to determine the minimum number of additional ingredients required such that there are exactly k distinct freshness levels available.
If the number of unique freshness levels among the given ingredients is \(n_{\text{unique}}\), then the answer is computed as
For example, if you have 5 ingredients with freshness levels [3, 1, 4, 1, 5] and you need 7 distinct levels, you must add 3 more ingredients with new freshness levels.
inputFormat
The input consists of two lines:
- The first line contains two space-separated integers
n
andk
, wheren
is the number of ingredients andk
is the target number of distinct freshness levels. - The second line contains
n
space-separated integers representing the freshness levels of the ingredients.
outputFormat
Output a single integer, which is the minimum number of additional ingredients required to achieve exactly k
distinct freshness levels.
5 7
3 1 4 1 5
3
</p>