PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000271. Lập lịch công việc ngắn (Small Schedule)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Lập lịch công việc ngắn (Small Schedule)
Small Schedule
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
There are identical idle machines, jobs of duration one second and jobs of duration seconds. A job must run entirely on one machine, which processes at most one job at a time. Assign and order the jobs freely to minimize the completion time of all jobs.
Input
One line contains four integers , in that order.
Output
Print the minimum completion time in seconds.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input 1
2 4 3 6
Output 1
4
Explanation
Assign long jobs in counts (2,2,1,1), leaving four seconds on the last two machines for short jobs. Below four seconds each machine can handle only one long job.