#K65622. Book Bundling
Book Bundling
Book Bundling
You are given N books and an integer K. The ith book has a specified number of pages. Your task is to divide these books into K contiguous bundles such that the maximum sum of pages in any bundle is minimized.
Formally, if the bundles are represented as groups whose page sums are \(S_1, S_2, \dots, S_K\), you need to minimize \(\max(S_1, S_2, \dots, S_K)\).
You may assume that the books must remain in the given order and each bundle must contain at least one book.
inputFormat
The input is read from standard input (stdin) and has the following format:
N K p1 p2 ... pN
Where:
- N is the number of books.
- K is the number of bundles.
- p1, p2, ..., pN are the page counts of each book.
outputFormat
Output a single integer to standard output (stdout) representing the minimized maximum number of pages among the bundles.
## sample5 2
100 200 300 400 500
900