~/algor $ cat problems/qidiruv-kitoblarni-taqsimlash
Allocating books
$n$ books stand in a row on a shelf, the $i$-th book has $a_{i}$ pages. The books must be divided among $k$ students: each student gets at least one book, the books of one student stand next to each other on the shelf, and every book goes to exactly one student. The number of pages of the student who gets the most pages must be as small as possible. Find this number.
Input
The first line contains two positive integers: $n$ and $k$. The second line contains $n$ positive integers $a_{i}$ separated by spaces.
Output
One integer — the smallest possible number of pages of the student who gets the most pages.
Note
$1 \le k \le n \le 10^{5}$
$1 \le a_{i} \le 10^{4}$
Examples
5 2 10 20 30 40 50
90
4 4 7 2 9 4
9