Way via mountains#5852

Way via mountains

2 seconds
64 megabytes
Hard

The surface of the highland can be represented as a polygonal chain with vertices at the points (x_1, y_1), (x_2, y_2), \ldots, (x_N, y_N), where x_i < x_{i+1} for all i = 1, 2, \ldots, N-1. An ordinary mountain mage starts at the point (x_1, y_1) and wants to reach the point (x_N, y_N). He can move only on foot, either walking along the surface of the Earth (the polygonal chain) or by creating bridges in the air to walk across.

A bridge can connect two vertices of the polygonal chain: it must start and finish at some vertices, and it cannot pass underground (it cannot form a tunnel in the mountain). However, some points or segments of the bridge may touch the surface of the ground. The length of any bridge cannot exceed , and the mage cannot build more than bridges. After crossing a bridge, it disappears.

What is the minimum distance the mage must travel to reach the point (x_N, y_N)?

Input

The input contains the following:

- An integer (2 \le N \le 555), the number of vertices. - An integer (1 \le K \le 256), the maximum number of bridges. - An integer (0 \le R \le 10000), the maximum possible length of a bridge. - lines describing the coordinates of the vertices: (x_1, y_1), (x_2, y_2), \ldots, (x_N, y_N). All coordinates are integers with absolute value not exceeding . For all from to N-1, x_i < x_{i+1}.

Output

Print a single number: the minimum total distance the mage must travel (including both ground and bridge distances). Output the answer with at most digits after the decimal point.

Examples

Example 1

Loading
Loading