PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000238. Nhận dạng thuật toán: Chọn công việc có thưởng (Mixed Greedy Recognition 01)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nhận dạng thuật toán: Chọn công việc có thưởng (Mixed Greedy Recognition 01)
Mixed Greedy Recognition 01
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
There are jobs. Job starts at , ends at , and pays reward . One worker may perform only one job at a time. Two jobs are compatible if the earlier one ends no later than the later one's start.
Choose a non-overlapping subset maximizing total reward. You may select no jobs. This exercise contrasts maximum job count with maximum weighted reward.
Input
- The first line contains .
- Each of the next lines contains .
Output
Print the maximum achievable total reward.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
4
1 3 5
3 4 6
1 4 10
4 5 3
Output
14
Explanation
Choose jobs , , and , which do not overlap because an end may equal the next start. Their reward totals . Taking and gives only . The answer is .