Problem list
Log in
#usaco0162 · USACO 2014-2015 December Silver

Cow Jog (Silver)

Silver IV 2.0 s 256 MB

There are N cows jogging on an infinitely-long single-lane track (1 <= N <= 100,000). Each cow starts at a distinct position, and some cows jog at different speeds. With only one lane, cows cannot pass each other; when a faster cow catches up to another cow, she slows down and becomes part of the same group.

The cows will run for T minutes (1 <= T <= 1,000,000,000). Please help Farmer John determine how many groups will be left at this time. Two cows are part of the same group if they are at the same position at the end of T minutes.

Input

  • Line 1: The two integers N and T.
  • Lines 2..1+N: Each contains the initial position and speed of a single cow (both nonnegative/positive integers at most 1 billion). All cows start at distinct positions, given in increasing order.

Output

A single integer indicating how many groups remain after T minutes.

Example 1

Input
5 3
0 1
1 2
2 3
3 2
6 1
Output
3
Source
USACO 2014-2015 December Silver
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code