
Fax McClad, Croneria's most well respected bounty hunter, needs to renew his flight license. In order to do so, he will have to take a flight examination.
For the examination, Fax is required to fly straight, but he can change his altitude. In front of him, there are
Fax can increase his altitude at a rate of up to
Fax is able to do a special technique called the somersault. When he performs this technique, he will rise
Fax's exam ends when there are no more checkpoints in front of him. His score is determined by the number of checkpoints he passes. What is the maximum number of checkpoints that Fax can pass through?
Constraints
For 40% of the points,
Note to Python users: It is recommended to submit in PyPy.
Input Specification
The first line of input will contain four space-separated integers:
Output Specification
Output a single integer, the maximum number of checkpoints that Fax can pass through.
Sample Input
6 400 200 300
2 600
3 1000
3 1200
3 1300
5 700
6 200
Sample Output
4
Diagram for Sample
The black points signify the checkpoints, and the red line is the optimal path that Fax McClad can take.
Comments
Can he perform the somersault when he is not currently at a checkpoint?
Yes.