#P3111. [USACO14DEC] Cow Jog S
[USACO14DEC] Cow Jog S
Description
There are cows jogging on an infinitely long single-lane track, where . Each cow starts at a distinct position on the track, and some cows jog at different speeds.
Since the track has only one lane, cows cannot pass each other. When a faster cow catches up to a slower cow, she must slow down to avoid running into her, becoming part of the same running group.
The cows will run for minutes, where . Please determine how many groups remain at that time. Two cows are considered part of the same group if they are at the same position at the end of minutes.
Input Format
- The first line contains two integers and .
- Each of the following lines contains two integers: the initial position and speed of a single cow. The position is a nonnegative integer and the speed is a positive integer; both are at most . All cows start at distinct positions, given in increasing order.
Output Format
Output a single integer indicating how many groups remain after minutes.
5 3
0 1
1 2
2 3
3 2
6 1
3
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号