luogu#P10934. 西瓜种植
西瓜种植
Background
Benben: Little watermelons, little watermelons~
Passer-by A: No way. These watermelons are clearly big...
Benben: Then... big watermelons, big watermelons~
Passer-by A: You changed your words so fast...
Benben: Watermelons, watermelons~ Cute watermelons~
Problem Description
Benben planted a watermelon field, but the planting area of this field is a straight line...
After some research, Benben came up with conclusions. These conclusions can maximize the number of watermelons he harvests.
Benben's conclusions are as follows:
From position to position in the field, at least watermelons must be planted, and then the harvest in this range can be maximized.
Benben does not want to work that hard, so he wants to plant as few watermelons as possible, while satisfying every conclusion he obtained.
Input Format
The first line contains two numbers and (, ), meaning Benben's watermelon field has length , and Benben has obtained conclusions.
The next lines describe Benben's conclusions. Each line contains three numbers , , (, ).
Output Format
Output the minimum number of watermelons Benben needs to plant.
9 4
1 4 2
4 6 2
8 9 2
3 5 2
5
Hint
Basically, Benben's watermelon field is a spectacular line...
Translated by ChatGPT 5