#P4087. Milk Measurement
Milk Measurement
Milk Measurement
Farmer John's cows each initially produce \(G\) gallons of milk per day. Over time, their milk production may change. Farmer John records these changes in his log book. A log entry is formatted as follows:
day cowID change
For example, the following entries:
35 1234 -2 14 2345 +3
indicate that on day 35, cow #1234's milk output decreased by 2 gallons compared to its previous measurement, and on day 14, cow #2345's milk output increased by 3 gallons compared to its previous measurement.
Farmer John proudly displays the pictures of the cow(s) with the highest milk output in his barn. If multiple cows tie for the highest production, all of their pictures are displayed. Since there are plenty of cows that are not mentioned in the log (each still producing \(G\) gallons), your task is to determine the number of days on which the display changes.
Note: The log entries are not necessarily given in chronological order, and there is at most one measurement per day.
inputFormat
The first line contains two integers \(N\) and \(G\):
- \(N\) (\(1 \le N \le 100,000\)) is the number of log entries.
- \(G\) (\(1 \le G \le 10^9\)) is the initial milk production of every cow.
Each of the next \(N\) lines contains a log entry with three tokens:
- day (an integer)
- cowID (an integer)
- change (a signed integer, for example, +3 or -2)
Note that the measurements are not necessarily in chronological order and there is at most one measurement per day.
outputFormat
Output a single integer representing the number of days on which Farmer John had to change his display of cow pictures.
sample
3 10
4 2 -1
7 3 +3
9 3 -2
1