#K5661. Rhythm Game Maximum Score
Rhythm Game Maximum Score
Rhythm Game Maximum Score
You are given a musical rhythm game with multiple levels. In each level, you are provided with notes represented as intervals. Each note is given in the form (start, end, points), where start and end are the start and end times of the note, and points is the score obtained by playing that note.
Your task is to choose a subset of notes from each level such that no two chosen notes overlap. Two notes are considered non-overlapping if the ending time of one note is less than or equal to the starting time of the other note. Formally, if you select notes i and j (with i chosen before j), then they must satisfy:
\( end_i \leq start_j \)
You need to compute the maximum total points that can be achieved for each level by selecting non-overlapping notes optimally.
Input and Output: The problem is input/output based. You will read from standard input and write your answer to standard output.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer T representing the number of levels.
- For each level, the first line contains an integer N, the number of notes in that level.
- This is followed by N lines, each containing three integers: start, end, and points, which represent the start time, end time, and point value of the note, respectively.
For example:
2 4 0 3 10 1 5 5 4 6 3 5 8 8 3 2 4 6 1 3 4 0 2 5
outputFormat
The output should be written to standard output (stdout) and contain T lines. Each line contains a single integer representing the maximum total points that can be achieved in the corresponding level by choosing non-overlapping notes optimally.
For the sample above, the output should be:
18 11## sample
2
4
0 3 10
1 5 5
4 6 3
5 8 8
3
2 4 6
1 3 4
0 2 5
18
11
</p>