408017: GYM102961 ZE Array Division

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

ZE. Array Divisiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given an array containing $$$n$$$ positive integers.

Your task is to divide the array into $$$k$$$ subarrays so that the maximum sum in a subarray is as small as possible.

Input

The first input line has two integers $$$n$$$ and $$$k$$$.

The next line has $$$n$$$ integers $$$x_1,x_2,\dots,x_n$$$: the contents of the array.

Constraints:

  • $$$1 \le k \le n \le 2 \cdot 10^5$$$
  • $$$1 \le x_i \le 10^9$$$
Output

Print one integer: the maximum sum in a subarray in the optimal division.

ExampleInput
5 3
2 4 7 3 5
Output
8

加入题单

上一题 下一题 算法标签: