#P2190. 小Z的车厢
小Z的车厢
Description
In Xiao Z's hometown, there is a train running on a circular railway, stopping at stations (stations to arranged clockwise).
As everyone knows, the Spring Festival travel rush is a terrible thing. Unfortunately, Xiao Z is an employee of the railway company, and he has received booking requests for the early hours of Chinese New Year's Eve. Each request means there are people traveling clockwise from station to station . At each stop at a station, all passengers who need to board at that station will get on, and all passengers who need to alight at that station will get off.
Since the starting station is not fixed, Xiao Z wants to know the minimum number of carriages that must be assigned to this train (each carriage can carry people) to complete the transportation, and he hopes you can help him.
Input Format
The first line contains two integers .
The next lines each contain three integers .
Output Format
The first line contains an integer, representing the minimum number of carriages required for this train.
3 2
1 2 36
2 3 36
1
4 2
1 2 36
4 3 36
2
Hint
Constraints
For of the testdata, , ;
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号