PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000256. Đóng đồ vào thùng lớn (Big Boxes)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đóng đồ vào thùng lớn (Big Boxes)
Big Boxes
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
Brandon Greg Jr. is moving to the United States. His items are in a fixed order; item weighs . Pack them into exactly nonempty consecutive groups, one per box. Ignore the empty boxes’ weight. Minimize the heaviest loaded box.
Input
The first line contains integers , the item and box counts. The second contains the integer weights in order.
Output
Print the minimum possible weight of the heaviest box.
Subtasks
- Subtask 1 (20 points): ; for all .
- Subtask 2 (30 points): ; for all . .
- Subtask 3 (50 points): ; for all .
Examples
Input
7 2
3 1 1 3 9 5 2
Output
16
Explanation
Cut after item 4: the weights are 8 and 16. At capacity 15 the first box cannot include item 5 because the prefix weighs 17. The remaining items weigh at least 16, so 16 is optimal.