Jumping Cat

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

A city skyline is specified by nn integers d_1,d_2,,d_nd\_1, d\_2, \ldots, d\_n (0<d_1<d_2<<d_n0 < d\_1 < d\_2 < \ldots < d\_n) and nn integers h_1,h_2,,h_nh\_1, h\_2, \ldots, h\_n.

A skyline surface consists of nn horizontal line segments, the ii-th segment connects points (d_i1,h_i)(d\_{i-1}, h\_i) and (d_i,h_i)(d\_i, h\_i), where d_0=0d\_0 = 0. Each segment is a roof of a building.

A cat (which is so small that can be considered a point) wants to get from the leftmost point of the skyline, (0,h_1)(0, h\_1), to the rightmost point of the skyline, (d_n,h_n)(d\_n, h\_n). To achieve that, the cat performs a sequence of moves. Each move is one of two types:

\begin{enumerate}

  1. Walk from point (x_1,y_1)(x\_1, y\_1) to point (x_2,y_2)(x\_2, y\_2). Both points must belong to the same surface segment, i. e. there exists ii such that y_1=y_2=h_iy\_1 = y\_2 = h\_i and d_i1x_1,x_2d_id\_{i-1} \le x\_1, x\_2 \le d\_i. A trajectory of a walk is a straight line segment. 

  2. Jump from point (x_1,y_1)(x\_1, y\_1) to point (x_2,y_2)(x\_2, y\_2). Points (x_1,y_1)(x\_1, y\_1) and (x_2,y_2)(x\_2, y\_2) must belong to different surface segments. A trajectory of a jump is a straight line segment and must satisfy the following constraints:

    • the distance between (x_1,y_1)(x\_1, y\_1) and (x_2,y_2)(x\_2, y\_2) is at most LL;
    • the line segment between (x_1,y_1)(x\_1, y\_1) and (x_2,y_2)(x\_2, y\_2) does not intersect any of the buildings, i. e. there is no point (x,y)(x, y) belonging to the segment and integer ii such that d_i1<x<d_id\_{i-1} < x < d\_i and y<h_iy < h\_i.

The length of the cat's trajectory is the sum of lengths of all the moves in it. Find the shortest trajectory for the cat to get from (0,h_1)(0, h\_1) to (d_n,h_n)(d\_n, h\_n), or determine that the goal is unreachable.

입력

The first line contains two integers nn and LL (1n501 \le n \le 50; 1L1001 \le L \le 100).

The second line contains nn integers d_1,d_2,,d_nd\_1, d\_2, \ldots, d\_n (0<d_1<d_2<<d_n10000 < d\_1 < d\_2 < \ldots < d\_n \le 1000).

The third line contains nn integers h_1,h_2,,h_nh\_1, h\_2, \ldots, h\_n (1h_i1001 \le h\_i \le 100; h_ih_i+1h\_i \ne h\_{i+1}).

출력

Output a single floating-point number --- the length of the shortest trajectory from point (0,h_1)(0, h\_1) to point (d_n,h_n)(d\_n, h\_n), or 1-1 if no valid trajectory exists.

Your answer will be considered correct if its absolute or relative error doesn't exceed 10910^{-9}.

힌트

The picture for the first sample is shown below.