Given fall speed, parachute glide speed, a walk speed, and cars parked at integer x positions, find the minimum time to reach the safe zone at x = Xe.
Medium6MathImplementationGreedyBrute forceNo attempts yetTime limit1sMemory limit512 MBGyuhwan started playing a battle royale game. A hundred players compete to survive on one two dimensional map that spans from (0,0) to (Sy,N). Coordinates are written in the order (y,x). Surviving to the end means taking a safe area early.
When the game starts, Gyuhwan falls straight down from the starting point S(Sy,Sx) at the constant speed g. During the free fall he cannot move left or right, and he may open the parachute at any moment he likes. Once the parachute is open he can move horizontally at a speed of at most a, and the falling speed drops to g/2. The horizontal speed is anything between 0 and a, and accelerating takes no time. The x coordinate of the landing point must always be an integer that is at least 0.
After he lands, meaning his y coordinate becomes 0, he can walk or drive a car. His walking speed is f, and there are M cars. Each car has a position P(0,Xp) and a speed Sp. A car accelerates in no time, switching cars takes no time, and turning a car around takes no time. No two cars sit at the same position.
There are three ways to reach the safe zone E(0,Xe). He can open the parachute and fly straight there, he can land and walk, or he can land and drive a car.
For example, take g=10, a=2, f=1 and the starting point S(100,100), as in the picture below. While falling, his speed along the x axis is 0 and his speed along the y axis is 10. After 5 seconds he is at (50,100). If he opens the parachute there and moves right at the top speed 2, his speed along the x axis becomes 2 and his speed along the y axis becomes 5, so 10 seconds later he arrives at (0,120). Taking car 1, which is parked there, gives him a speed of 60, and 1 second later he reaches the safe zone.

Find the earliest time at which Gyuhwan can reach the safe zone.
The first line contains the size of the map along the x axis N, the number of cars M, the vertical falling speed g, the maximum horizontal speed with an open parachute a, and the walking speed f. N is a natural number at most 200, M is 0 or a natural number at most 100, g is a natural number with 0<g≤1000, a is a natural number with 0<a≤100, and f is a natural number with 0<f≤50000.
The second line contains Sy and Sx of the starting point and the x coordinate of the safe zone Xe. Sy is a natural number with 0<Sy≤1000, Sx is an integer with 0≤Sx≤N, and Xe is an integer with 0≤Xe≤N.
Each of the next M lines contains the position of one car Xp and its speed Sp. Xp is an integer with 0≤Xp≤N, and Sp is a natural number with 0<Sp≤50000000.
Print the minimum time to reach the safe zone on one line, rounded to eight digits after the decimal point.