PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000231. Phân công công việc (Schedule Management)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Phân công công việc (Schedule Management)
Schedule Management
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are workers and tasks. Task has one proficient worker numbered . Assign every task to exactly one worker.
A worker completes a task in hour if proficient in it and otherwise needs hours. Workers process at most one task at a time but operate in parallel, starting at time .
Find the earliest possible time when all tasks are finished.
Input
- The first line contains .
- The next line contains integers , identifying the proficient worker for each task.
Output
Print the minimum completion time in hours.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
2 4
1 1 1 1
Output
3
Explanation
Worker is proficient in all four tasks; worker is proficient in none. Within hours, worker handles three tasks and worker handles the last in hours. Within hours, they can handle only two plus one tasks, so the minimum is .