the-maze-runner

One more nightmare... This time you got into a maze.

The maze is described by two polylines. Each of them has N + 1 points. The points of the first polyline are: (x0, y0), (x2, y2), ... , (xN, yN). The points of the second polyline are (x0, y0 + H), (x2, y2 + H), ... , (xN, yN + H).

The entrance to the maze is a segment (x0, y0) - (x0, y0 + H) and the exit is a segment (x0, y0) - (xN, yN + H).
During your running in the maze you can be in any point inside the maze.

The faster you go through the maze - the more chances to survive you have. You know description of the the maze. Find the length of the shortest path you have to run.

Input
The first line contains one integer N.
The following N + 1 lines contains 2 space-separated integers each - description of the first polyline.
The last line contains one integer H.

Output
Ouput one real number with exactly 10 digits after dot - the shortest distance you have to cover.

Constraints
1 ≤ N ≤ 100
|xi|, |yi|, H ≤ 10^4
x0 < x1 < ... < xN

SAMPLE INPUT
2
0 0
2 2
3 -1
2

SAMPLE OUTPUT
3.4142135624

Source: hackerearth | Difficulty: MEDIUM
Tags: Geometry


Solutions: