Under construction

Still being built. Things may change

Cetinska Road Construction

Time limit1sMemory limit2048 MB

Summary
Find the minimum cost of a road between the two ends of a south-to-north river polyline, where each meter of road costs 1 and each river crossing costs T.
Level

Hard8 of 10

Topics
Shortest path, Geometry
Solved
No attempts yet

Statement

A river runs through a desert, with a city on each of its two ends. The river is a polyline that starts at one city and ends at the other.

Every straight segment of the river flows strictly from south to north, that is, in the direction of increasing yy coordinate.

We must build a road connecting the two cities. The road may run along the river, but it cannot simply cross it: a bridge must be built at every crossing. Building one meter of road on the ground costs 11, and building each bridge (crossing) costs TT.

Traffic inside the cities is already handled, so the road may start and end on either bank of the river.

Input

The first line contains a natural number NN (2≤N≤15002 ≤ N ≤ 1500), the number of river vertices (including the cities), and a real number TT (0<T≤1060 < T ≤ 10^6), the cost of one bridge. TT has at most two decimal places.

Each of the next NN lines contains two integers XiX_i and YiY_i, the coordinates of the ii-th river vertex, with ∣Xi∣,∣Yi∣≤105|X_i|, |Y_i| ≤ 10^5. They satisfy Yi<Yi+1Y_i < Y_{i+1} for 1≤i<N1 ≤ i < N.

No three points in the input are collinear. The road must start at (X1,Y1)(X_1, Y_1) and end at (XN,YN)(X_N, Y_N).

Output

Print one number, the minimum possible cost of the project. The answer is accepted if it differs from the exact answer by at most 10−610^{-6}.

Hint

See the figure for the explanation of the first sample.

Examples2

  1. Example 1

    Input
    5 1
    0 0
    -1 2
    4 3
    -3 4
    1 5
    
    Expected output
    6.8416192530
    
  2. Example 2

    Input
    2 1
    0 0
    0 1
    
    Expected output
    1.0000000000