JOI '22 Open P1 - Seesaw
View as PDFA straight stick of length  is placed from the left to the right. You can ignore the weight of the stick. In total, 
 unit weights are attached to the stick. The positions of the 
 weights are different from each other. The position of the 
-th weight 
 is 
, i.e., the distance between the 
-th weight and the leftmost end of the stick is 
.
In the beginning, we have a box of width . We place the stick on the box so that the box supports the range from 
 to 
 of the stick 
, inclusive, i.e., the range of the stick from the point whose position is 
 to the point whose position is 
. Here, 
 is satisfied. We cannot change the values of 
 and 
 afterward.
Next, among the weights attached to the stick, we remove the leftmost one or the rightmost one. We shall repeat this operation  times. In this process, including the initial state and the final state, the barycenter of the weights attached to the stick should remain in the range from 
 to 
, inclusive. Here, if 
 weights are attached to the stick whose positions are 
, the position of the barycenter is 
.
Given the number of weights  and the positions of the weights 
, write a program which calculates the minimum possible width 
 of the box.
Input Specification
Read the following data from standard input. Given values are all integers.
Output Specification
Write one line to the standard output. The output should contain the minimum possible width  of the box. Your program is considered correct if the relative error or the absolute error of the output is less than or equal to 
. The format of the output should be one of the following.
- Integer. (Example: 
,
,
)
 - A sequence consisting of an integer, the period, a sequence of numbers between 
and
. The numbers should not be separated by symbols or spaces. There is no restriction on the number of digits after the decimal point. (Example:
,
,
)
 
Constraints
.
.
Subtasks
- (1 point) 
.
 - (33 points) 
.
 - (33 points) 
.
 - (33 points) No additional constraints.
 
Sample Input 1
3
1 2 4
Sample Output 1
0.8333333333
Explanation for Sample 1
Let the width of the box be . We put 
, 
. We perform the following operations.
- In the beginning, the position of the barycenter is 
.
 - In the first operation, we remove the rightmost weight (the weight whose position is 
). Then the barycenter becomes
.
 - In the second operation, we remove the leftmost weight (the weight whose position is 
). Then the barycenter becomes
.
 
In this process, the barycenter remains in the range from  to 
. Since the width of the box cannot be smaller than 
, output 
 in a decimal number.
This sample input satisfies the constraints of all the subtasks.
Sample Input 2
6
1 2 5 6 8 9
Sample Output 2
1.166666667
This sample input satisfies the constraints of all the subtasks.
Comments