No.3422 Sazanka's hobby
Problem Statement
Sazanka is growing $N$ plants. The height of the $i$-th plant on the morning of day $1$ is $a_i$, and every day it grows taller by $b_i$ during the night.
The height of Sazanka's room is $M$. If a plant becomes taller than that, it breaks through the ceiling and the room starts to leak. To prevent this, every morning Sazanka removes up to $k$ plants from the room.
Since Sazanka wants to look at the plants for as long as possible, he has decided to find the minimum $k$ required to keep the room from leaking.
Constraints
- $1 \leq N \leq10^6$
- $1 \leq M \leq10^9$
- $0 \leq a_i \leq M$
- $1\leq b_i \leq10^9$
- All inputs are integers.
Input
The input is given from standard input in the following format.
$N$ $M$ $a_1$ $b_1$ $a_2$ $b_2$ ⋮ $a_N$ $b_N$
Output
Output the minimum $k$ required to keep the room from leaking.
Sample
Sample 1
Input
3 5 2 2 2 3 3 2
Output
2
On the night of day $1$, the heights of the plants become $4,5,5$. On the night of day $2$, they become $6,8,7$.
If $k = 1$, at most $2$ plants can be removed by the night of day $2$, so the remaining $1$ plant breaks through the ceiling.
With $k = 2$, the leak can be prevented.
Sample 2
Input
5 10 2 4 3 4 1 2 6 10 3 4
Output
2
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
まみめ
kidodesu