PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000039. Lập lịch hai máy (Setting Problems)
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 hai máy (Setting Problems)
Setting Problems
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
There are jobs. Job requires time on machine 1 and then time on machine 2. Each machine handles one job at a time and every job uses machine 1 before machine 2. Choose a common order minimizing the makespan.
Input
The first line contains . The second line contains and the third line contains .
Output
Print the minimum makespan.
Constraints
- .
- for .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): Full constraints.
Examples
Input
3
2 4 3
5 1 2
Output
10
Explanation
The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.