Path Through the Mountains 2#814

Path Through the Mountains 2

1 second
256 megabytes
Very hard

The Earth's surface in a mountainous region can be represented as a polyline. The vertices of this polyline are at points \left(x_1, y_1\right), \left(x_2, y_2\right), \ldots, \left(x_N, y_N\right), where x_i < x_{i+1} for each .

A mountain mage is located at \left(x_1, y_1\right) and wishes to reach \left(x_N, y_N\right). The mage can move:

A bridge must satisfy the following:

What is the minimum distance the mage must travel (walking both along the surface and on bridges) to reach the point \left(x_N, y_N\right)?

Input

The input consists of:

  • An integer (2 \leq N \leq 64).

  • An integer (0 \leq R \leq 10000) — the maximum allowed length of one bridge.

  • An integer (R \leq S \leq 10000) — the maximum total length for the bridges.

  • Then, pairs of integers \left(x_1, y_1\right), \left(x_2, y_2\right), \ldots, \left(x_N, y_N\right).

All coordinates are integers with absolute value not exceeding . For every from to N-1, x_i < x_{i+1}.

Output

Print a single number — the minimum length of the path the mage must take (walking along the polyline and via bridges). Output the answer with exactly digits after the decimal point.

Examples

Example 1

Loading
Loading