#CT0000073. Phân lô hàng (Cargo Lot Partitioning)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Phân lô hàng (Cargo Lot Partitioning)
Cargo Lot Partitioning
Version: Phuoc Hung OJ Extended
Problem Statement
A warehouse contains parcels arranged in their original order from to . Parcel has weight .
The warehouse manager must divide all parcels into at most lots. Each lot must be nonempty and contain a contiguous block of parcels. Every parcel belongs to exactly one lot, and the original order cannot be changed.
The weight of a lot is the sum of the weights of its parcels. For any partition, consider the weight of its heaviest lot.
Task: Minimize that heaviest-lot weight over all valid partitions.
Input
- The first line contains two positive integers and .
- The second line contains exactly positive integers , the parcel weights in order.
Output
Print one integer: the smallest achievable weight of the heaviest lot.
Subtasks
- Subtask 1 (25 points): ; for all .
- Subtask 2 (35 points): ; for all .
- Subtask 3 (40 points): ; for all .
Examples
Example 1
Input
5 3
7 2 5 10 8
Output
14
Explanation
Partitioning into [7, 2, 5], [10], [8] yields lot weights , with maximum . A maximum below is impossible: with a limit of , the parcel of weight cannot join the first pair of weights or the following parcel of weight , so at least four lots would be needed.
Example 2
Input
4 2
2 2 2 2
Output
4
Explanation
Split [2, 2, 2, 2] into [2, 2] and [2, 2]. Both lots weigh . As the total weight is , at most two lots cannot both weigh less than .
Example 3
Input
3 1
5 1 4
Output
10
Explanation
With , all parcels of weights must belong to the sole lot, giving weight .
Liên quan
Trong các cuộc thi sau: