High Jump

4.6

11 votes
Sorting, Algorithms, Easy-Medium, Sorting
Problem

There's a line of L meters. You need to start at 0, and arrive L. There are N obstacles on the line. Each obstacle has a position pi and height hi.

You have two ways to move, first one - just walk towards the destination, second one - jump to avoid obstacles.

If you are X meters far from the start point, and Y meters high, we say you are at (X,Y). A jump means, start from (X,0), travel along the line (X,0)(X+YA,Y) and then (X+YA,Y)(X+2YA,0), which (X,0) is the start position of the jump, and Y is the height of the jump. If one of the two lines pass through any obstacle, this jump is illegal (It's legal to pass through the highest point of a obstacle). The height Y is decide by yourself, but it should less than M. A is your rising speed and falling speed.

Arrive L means, your position should be (L,0) at some time.

You need to determine if it's possible to arrive L.

Input Format

First line contains four integers, N,M,L,A(1N105,1M,L,A109).

The (i+1) th line contains two integers, pi,hi(1pi<L,1hi109).

Output Format

"Yes" or "No".

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Check this graph. The red line is your path, the blue line is the height limit, and the black lines are the obstacles. In this sample, if M=10, the result will be "No".

Editor Image

?