#K48452. Fair Book Distribution
Fair Book Distribution
Fair Book Distribution
You are given a collection of n books and k members of a book club. The books are represented by a list where each element indicates the number of pages in a book. However, for the purpose of this problem, the pages of the books do not affect the distribution.
Your task is to distribute all the books among the members such that the books are as evenly distributed as possible. Each member will receive either \(\lfloor n/k \rfloor\) or \(\lceil n/k \rceil\) books. You need to determine the maximum number of books any single member can receive after the distribution.
Note: Even though a list of pages is given as input, it is not used in the calculation. The answer is essentially the ceiling of \(n/k\), which can be computed by the formula \(\lceil n/k \rceil = \frac{n+k-1}{k}\) (using integer division).
Examples:
- Input: n = 7, k = 3, pages = [2, 3, 4, 5, 6, 7, 8] → Output: 3
- Input: n = 5, k = 2, pages = [10, 20, 30, 40, 50] → Output: 3
- Input: n = 1, k = 1, pages = [5] → Output: 1
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains two integers, n and k, where n is the total number of books and k is the number of members.
- The second line contains n integers representing the number of pages in each book (this data is provided but not used in the calculation).
outputFormat
Output a single integer to the standard output (stdout): the maximum number of books any member will receive after a fair distribution.
## sample7 3
2 3 4 5 6 7 8
3