#BS0000324. Hoàn thành mọi công việc (Find Minimum Time to Finish All Jobs)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Hoàn thành mọi công việc (Find Minimum Time to Finish All Jobs)
Find Minimum Time to Finish All Jobs
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
There are independent jobs and workers. Job takes units of time and must be assigned entirely to one worker.
A worker performs assigned jobs sequentially, spending their total duration, or zero time if no job is assigned. Different workers may work simultaneously.
Assign every job so that the greatest workload among the workers is as small as possible.
Input
The first line contains two integers , the numbers of jobs and workers.
The second line contains integers , the job durations.
Output
Print one integer: the smallest possible maximum workload.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; .
Examples
Input 1
5 2
1 2 4 7 8
Output 1
11
Explanation
Assign durations 1, 2, 8 to one worker and 4, 7 to the other. Each works for 11 units. Since total work is 22, at least one worker must spend at least 11 units.
Input 2
3 3
3 2 3
Output 2
3
Explanation
Give each worker one job, with durations 3, 2 and 3. A job of duration 3 cannot be split, so 3 is also a lower bound.