#P1250. 种树
种树
Description
The roadside area is divided into blocks and numbered . Each block has unit size and can contain at most one tree.
Each resident wants to plant some trees in front of their house and specifies three numbers , , . These numbers mean that the resident wants at least trees in the area between and (inclusive of and ).
Different residents’ desired intervals may overlap. Your task is to find the minimum number of trees that can satisfy all requirements.
Input Format
The first line contains an integer, the number of areas .
The second line contains an integer, the number of houses .
Lines to each contain three integers. On line , the integers are , meaning the -th resident wants at least trees between and .
Output Format
Output a single integer, the minimum number of trees.
9
4
1 4 2
4 6 2
8 9 2
3 5 2
5
Hint
Constraints
For of the testdata, it is guaranteed that:
- ,。
- ,。
Translated by ChatGPT 5
京公网安备 11011102002149号