Contest
InterviewTime limit1sMemory limit256 MB
Given N intervals with start time, end time, and prize money, choose non-overlapping contests (end must not touch the next start) to maximize total prize.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Sorting, Binary search, Intervals
- Solved
- No attempts yet
Statement
Seungmin is the best programmer in the world, and everyone knows that he takes first place whenever he enters a contest. He has decided to enter several programming contests to earn prize money, and there are contests in total.
Naturally, if contests overlap in time, he cannot enter several of them at once. So, given the start time, end time, and prize money of each of the contests, Seungmin will enter contests in a way that earns him the most prize money. Naturally, he can receive the prize money from every contest he enters. Also, to allow for travel time, the end time of a contest must not equal the start time of the next contest.
Input
The first line gives . ()
The next lines give information about the contests. Each line contains , , separated by spaces in that order. This means the -th contest starts at time , ends at time , and has prize money . (, )
Output
Print the maximum prize money Seungmin can receive.