#K90467. Minimum Number of Shelves
Minimum Number of Shelves
Minimum Number of Shelves
You are given a collection of m books with various heights. Books with the same height must be placed on shelves separately because a single shelf can hold at most c books of the same height.
For each distinct height \(h\), if there are \(n_h\) books, then the number of shelves needed for that height is given by \(\lceil \frac{n_h}{c} \rceil\). The total number of shelves required is the sum of the shelves needed for each distinct height.
Your task is to determine and output the minimum number of shelves required to store all the books.
inputFormat
The input is given from standard input (stdin) and consists of two lines:
- The first line contains two integers
m
andc
wherem
is the number of books, andc
is the maximum number of books that can be placed on a shelf (for books of the same height). - The second line contains
m
space-separated integers representing the heights of the books.
outputFormat
Output a single integer on standard output (stdout) — the minimum number of shelves required to store all the books.
## sample5 2
1 2 1 2 1
3
</p>