PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000469. Các dự án (Projects)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Các dự án (Projects)
Projects
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
There are projects, each with start , end and reward for completing it. Select any subset of the projects without overlap. Both endpoints are inclusive, so the next start must be strictly greater than the previous end. 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
2 4 4
3 6 6
6 8 2
5 7 3
Output
7
Explanation
Choose projects 1 and 4 for reward 7. Project 2 overlaps all others; project 3 can only join project 1 for 6.