Cow Jog
InterviewTime limit1sMemory limit256 MB
Count the groups of cows that end at the same position after T minutes when no cow can pass the cow ahead.
Problem
The cows are out exercising their hooves again. cows are jogging on an infinitely long single-lane track (). Every cow starts at a different position, and some cows jog at different speeds.
The track has only one lane, so a cow cannot pass the cow ahead of her. When a faster cow catches up to the cow ahead, she slows down to avoid running into her and becomes part of the same group.
The cows run for minutes (). Determine how many groups are left at that point. Two cows count as the same group if they are at the same position at the end of the minutes.
Input
The first line contains the two integers and .
Each of the next lines contains the starting position and the speed of one cow. The position is a nonnegative integer and the speed is a positive integer, and both are at most 1 billion. All cows start at different positions, and the positions are given in increasing order.
Output
Print a single integer, the number of groups that remain after minutes.