#P8387. [COI 2021] Autobahn
[COI 2021] Autobahn
Problem Description
Translated from COI 2021 T1 “Autobahn”
There are people racing on a track. Person races from the beginning of hour to the end of hour .
Since the track wants to make money, it charges one unit of money for each hour of racing. However, these people have only paid for the first hours.
The administrators are very kind: they will only come to collect additional money when there are at least people racing on the track.
The track runs a promotion: it must choose a time interval of length hours. During this interval, if someone would need to pay extra money, then they do not need to pay the unpaid money corresponding to this interval.
The track wants this promotion to maximize the total amount of money that these people do not need to pay extra. Find this maximum amount.
Input Format
The first line contains three integers , , and .
The next lines each contain three integers , , and .
Output Format
Output a single integer, the answer.
5 3 4
2 1 4
3 3 7
3 3 8
1 5 7
5 3 8
7
3 2 22
7 16 33
69 14 88
8 10 97
27
Hint
[Sample Explanation]
Sample #1 explanation:
The chosen interval is . In it, the first person does not need to pay the fee for hour , and the second, third, and fourth people do not need to pay the fees for hours and .
Sample #2 explanation:
The chosen interval is .
[Constraints]
For of the testdata, , , and .
| Subtask | Constraints | Score |
|---|---|---|
| No additional constraints |
Translated by ChatGPT 5