Score : 400 points
In the year 2168, AtCoder Inc., which is much larger than now, is starting a limited express train service called AtCoder Express.
In the plan developed by the president Takahashi, the trains will run as follows:
According to the specifications of the trains, the acceleration of a train must be always within ±1m/s^2. Additionally, a train must stop at the beginning and the end of the run.
Find the maximum possible distance that a train can cover in the run.
Input is given from Standard Input in the following format:
N t_1 t_2 t_3 … t_N v_1 v_2 v_3 … v_N
Print the maximum possible that a train can cover in the run.
Output is considered correct if its absolute difference from the judge's output is at most 10^{-3}.
1 100 30
2100.000000000000000
The maximum distance is achieved when a train runs as follows:
The total distance covered is 450 + 1200 + 450 = 2100 meters.
2 60 50 34 38
2632.000000000000000
The maximum distance is achieved when a train runs as follows:
The total distance covered is 578 + 884 + 144 + 304 + 722 = 2632 meters.
3 12 14 2 6 2 7
76.000000000000000
The maximum distance is achieved when a train runs as follows:
The total distance covered is 18 + 12 + 16 + 28 + 2 = 76 meters.
1 9 10
20.250000000000000000
The maximum distance is achieved when a train runs as follows:
The total distance covered is 10.125 + 10.125 = 20.25 meters.
10 64 55 27 35 76 119 7 18 49 100 29 19 31 39 27 48 41 87 55 70
20291.000000000000