← 返回 meta 的题目列表Minimum Capacity of Ship to Deliver Packages
类型:online_judge
A conveyor belt has packages that must be shipped from one port to another within D days. The ith package on the conveyor belt has a weight of weights[i].
Each day, we load the ship with packages from the conveyor belt in the order given by weights. We cannot exceed the maximum weight capacity of the ship. Find the minimum capacity of the ship to deliver the packages within D days.
Input: A positive integer array weights representing the weight of packages and an integer days for the number of days to ship. Output: The minimum ship capacity to deliver the packages within D days.
Example:
Input: weights = [3,2,2,4,1,4], days = 3
Output: 6
Requirement: Implement a function min_cap(weights: list[int], days: int) -> int that solves this problem and specify its time complexity.
Example
Input
3,2,2,4,1,4
3