#abc076d. [abc076_d]AtCoder Express
[abc076_d]AtCoder Express
Score : points
Problem Statement
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:
- A train will run for seconds.
- In the first seconds, a train must run at a speed of at most m/s (meters per second). Similarly, in the subsequent seconds, a train must run at a speed of at most m/s, and so on.
According to the specifications of the trains, the acceleration of a train must be always within . 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.
Constraints
- All input values are integers.
Input
Input is given from Standard Input in the following format:
… …
Output
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 .
Sample Input 1
1
100
30
Sample Output 1
2100.000000000000000
The maximum distance is achieved when a train runs as follows:
- In the first seconds, it accelerates at a rate of , covering meters.
- In the subsequent seconds, it maintains the velocity of , covering meters.
- In the last seconds, it decelerates at the acceleration of , covering meters.
The total distance covered is + + = meters.
Sample Input 2
2
60 50
34 38
Sample Output 2
2632.000000000000000
The maximum distance is achieved when a train runs as follows:
- In the first seconds, it accelerates at a rate of , covering meters.
- In the subsequent seconds, it maintains the velocity of , covering meters.
- In the subsequent seconds, it accelerates at a rate of , covering meters.
- In the subsequent seconds, it maintains the velocity of , covering meters.
- In the last seconds, it decelerates at the acceleration of , covering meters.
The total distance covered is + + + + = meters.
Sample Input 3
3
12 14 2
6 2 7
Sample Output 3
76.000000000000000
The maximum distance is achieved when a train runs as follows:
- In the first seconds, it accelerates at a rate of , covering meters.
- In the subsequent seconds, it maintains the velocity of , covering meters.
- In the subsequent seconds, it decelerates at the acceleration of , covering meters.
- In the subsequent seconds, it maintains the velocity of , covering meters.
- In the last seconds, it decelerates at the acceleration of , covering meters.
The total distance covered is + + + + = meters.
Sample Input 4
1
9
10
Sample Output 4
20.250000000000000000
The maximum distance is achieved when a train runs as follows:
- In the first seconds, it accelerates at a rate of , covering meters.
- In the last seconds, it decelerates at the acceleration of , covering meters.
The total distance covered is + = meters.
Sample Input 5
10
64 55 27 35 76 119 7 18 49 100
29 19 31 39 27 48 41 87 55 70
Sample Output 5
20291.000000000000