#P3111. Cow Jog Groups
Cow Jog Groups
Cow Jog Groups
There are N cows jogging on an infinitely-long single-lane track for T minutes. Each cow starts at a distinct position and has its own speed. Since the track is single-lane, cows cannot pass each other. When a faster cow catches up to a slower cow ahead, it must slow down and join that cow’s group, running together at the slower speed.
Two cows are considered to be in the same group if they are at the same position after T minutes. Given the initial positions and speeds of the cows, determine how many groups will be present at time T.
Note: The constraints are given by \(1 \leq N \leq 100000\) and \(1 \leq T \leq 10^9\).
inputFormat
The first line contains two space-separated integers N and T, where N is the number of cows and T is the time in minutes.
The following N lines each contain two space-separated integers representing the starting position and speed of a cow.
It is guaranteed that all starting positions are distinct.
outputFormat
Output a single integer representing the number of groups present after T minutes.
sample
5 3
0 1
1 2
2 3
3 2
6 1
3