#BS0000021. Chia mảng (Array Division)
Chia mảng (Array Division)
Array Division
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array of positive integers, divide it into exactly non-empty contiguous subarrays covering the whole array. If the sum of subarray is , minimize
Input
The first line contains . The second line contains .
Output
Print the minimum possible value of the maximum subarray sum.
Subtasks
- Subtask 1 — 20%: or .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: , , .
Examples
Input
5 3
2 4 7 3 5
Output
8
Explanation
An optimal division is , whose maximum sum is .