Problems > Fair Reading Load

Fair Reading Load

Difficulty: 1600 3500 ms 128 MB

binary-search

N books (page counts given) must be split among K students; each student reads a contiguous block, every book is read. Minimize the maximum pages any one student reads and print that value.

Input: the first line has N and K (K ≤ N); the second line has the page counts.

Output: the minimized maximum load.

Constraints:

  • 1 ≤ K ≤ N ≤ 105
  • 1 ≤ pagesi ≤ 104

Sample Tests

Input 1
4 2
12 34 67 90
Output 1
113
Input 2
2 2
5 5
Output 2
5

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.