#P12247. Maximizing Excitement on the Dance Machine
Maximizing Excitement on the Dance Machine
Maximizing Excitement on the Dance Machine
In Electric Van City, there is a popular dance machine whose operation is critical for the business. At any given time, at most one player can use the dance machine, and each game lasts exactly consecutive minutes. The van city operates for minutes per day. There are players numbered from to . The -th player remains in the city from minute to minute (inclusive) and can play any number of games provided that each game is completely played within their time interval. Each completed game played by the -th player contributes an excitement value of . When a game is scheduled at time , it occupies the interval . A player can only participate in that game if and only if ( l_i \le s ) and ( s+k-1 \le r_i ). Games must not overlap. Your task is to design a schedule (i.e. select starting times for some game sessions) such that the total excitement value is maximized.
inputFormat
The first line of input contains three integers (n), (m), and (k). Each of the following (n) lines contains three space-separated integers (l_i), (r_i), and (w_i), describing the arrival time, departure time, and excitement value for the (i)-th player.
outputFormat
Output a single integer: the maximum total excitement value that can be achieved by scheduling non-overlapping game sessions.
sample
3 20 5
1 10 3
6 20 4
12 20 5
16