| Author: | Pavel Mesenev | Time limit: | 5 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
You are given an array of n positive integers a0, a1, …, an − 1 and an integer k. Cut the array into exactly k non-empty contiguous parts: choose k − 1 split points so that every element belongs to exactly one part and the parts appear in the original order.
The cost of a cut is the largest part sum among the k parts. Find the minimum possible cost over all valid cuts.
The first line contains two integers n and k. The second line contains n space-separated integers a0… an − 1.
Print one integer — the minimum possible value of the largest part sum.
1 ≤ k ≤ n ≤ 2 ⋅ 105
1 ≤ ai ≤ 109
The answer fits into a signed 64-bit integer.
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|