#Q2. 「一本通 1.1 例 2」种树
「一本通 1.1 例 2」种树
Description
A street is divided into segments, numbered consecutively from to . Each segment can plant at most one tree. Residents have provided sets of suggestions, each consisting of three integers , , and , indicating that residents wish to plant at least trees between segments and (inclusive). The intervals suggested by these recommendations may overlap. The question is: what is the minimum number of trees that need to be planted to satisfy all residents' suggestions?
Input Format
The first line contains , the number of street segments.
The second line contains , the number of suggestions.
The following lines each describe a suggestion with three integers: , , , separated by spaces.
Output Format
Output a single integer representing the minimum number of trees required to meet all residents' suggestions.
Sample 1
9
4
1 4 2
4 6 2
8 9 2
3 5 2
5
Data Range and Hints
For of the data, and ;
For of the data, , , , and .