#P1986. 元旦晚会
元旦晚会
Description
Brett’s class will perform as follows: all students stand in a line, each holding a microphone, singing in unison the theme of "Pleasant Goat and Big Big Wolf" (this act looks a bit silly).
The class is divided into voice parts. Each voice part consists of consecutive students. The -th voice part consists of students from to inclusive.
However, a student may belong to multiple voice parts, and some students may belong to none. To ensure singing quality, the -th voice part must have at least students holding microphones (that is, the number of students holding microphones within the -th voice part is at least ).
Please compute the minimum number of microphones that Brett’s class needs.
Input Format
The first line contains two positive integers .
The next lines each contain three positive integers .
Output Format
Output a single positive integer: the minimum number of microphones required to satisfy all constraints.
11 5
3 7 3
8 10 3
6 8 1
1 3 1
10 11 1
6
Hint
For of the testdata, it is guaranteed that , , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号