PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000462. Lập lịch công việc có lợi nhuận lớn nhất (Maximum Profit in Job Scheduling)
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 có lợi nhuận lớn nhất (Maximum Profit in Job Scheduling)
Maximum Profit in Job Scheduling
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
There are jobs, each with start , end and reward for completing it. Select any subset of the jobs without overlap. A job may start exactly when the previous job ends. Maximize the total reward.
Input
The first line contains . The next lines each contain three integers .
Output
Print the largest total reward.
Subtasks
- Subtask 1 (20 points): ; ; ().
- Subtask 2 (30 points): ; ; ().
- Subtask 3 (50 points): ; ; ().
Examples
Example 1
Input
4
1 3 50
2 4 10
3 5 40
3 6 70
Output
120
Explanation
Choose jobs 1 and 4; equality at time 3 is allowed.
Example 2
Input
5
1 3 20
2 5 20
3 10 100
4 6 70
6 9 60
Output
150
Explanation
Jobs 1,4,5 yield 150.
Example 3
Input
3
1 2 5
1 3 6
1 4 4
Output
6
Explanation
All start together; job 2 gives 6.