#P12247. Maximizing Excitement on the Dance Machine

    ID: 14353 Type: Default 1000ms 256MiB

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 kk consecutive minutes. The van city operates for mm minutes per day. There are nn players numbered from 11 to nn. The ii-th player remains in the city from minute lil_i to minute rir_i (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 ii-th player contributes an excitement value of wiw_i. When a game is scheduled at time ss, it occupies the interval [s,s+k1][s, s+k-1]. A player ii 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