260. Allocate the Books
n books stand in a fixed order, each with a page count. They must be split
among k students so that each student gets a CONTIGUOUS block and every book
is given out.
Print the smallest possible value of the largest number of pages any one
student receives. If there are more students than books, print -1.
Same shape again, and it is worth noticing why the bounds are what they are. No allocation can give a student fewer pages than the thickest single book, since that book must go to somebody whole. And one student taking everything is always achievable. So the answer lies between those two.
Constraints - `1 ≤ n ≤ 200000` - `1 ≤ k ≤ 200000` - `1 ≤ pages ≤ 1000000`
Input
The first line contains two integers n and k.
The second line contains n page counts in the fixed order.
Output
Print the minimised maximum pages, or -1 if k exceeds n.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.