175. Allocate Books
HardBinary Search on Answer
Split the books (in order, contiguous blocks) among m students, each getting at least one book, to minimise the maximum pages any student gets. Print that minimum.
Input format
Line 1: n m Line 2: pages of each book
Output format
The minimised maximum.
Example 1
Input
4 2 12 34 67 90
Output
113
Example 2
Input
3 3 10 20 30
Output
30
Constraints
1 ≤ m ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…