#K55007. Maximizing Distinct Vegetable Types
Maximizing Distinct Vegetable Types
Maximizing Distinct Vegetable Types
Sarah has \(n\) different types of seed and a total of \(m\) garden plots. She wants to use as many distinct seed types as possible when planting vegetables, with each plot accommodating one vegetable. Although she has specific seed counts for each type, she can only plant one vegetable per seed type if she has at least one seed. Hence, the answer is \(\min(n, m)\).
Given the total number of seed types \(n\), the number of garden plots \(m\), and a list of seed counts for each type, determine the maximum number of distinct vegetables Sarah can grow simultaneously.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains two integers: \(n\) (the number of seed types) and \(m\) (the number of garden plots).
- The second line contains \(n\) integers representing the number of seeds available for each type. (Note: The seed counts are provided but the answer depends only on \(n\) and \(m\).)
outputFormat
Output a single integer representing the maximum number of distinct types of vegetables that can be planted under the given constraints. The output is written to standard output (stdout).
## sample5 3
1 2 3 4 5
3
</p>