[BOJ 11748] Squeeze the Cylinders
View as PDFLaid on the flat ground in the stockyard are a number of heavy metal cylinders with (possibly) different diameters but with the same length. Their ends are aligned and their axes are oriented to exactly the same direction.</p>
We’d like to minimize the area occupied. The cylinders are too heavy to lift up, although rolling them is not too difficult. So, we decided to push the cylinders with two high walls from both sides.
Your task is to compute the minimum possible distance between the two walls when cylinders are squeezed as much as possible. Cylinders and walls may touch one another. They cannot be lifted up from the ground, and thus their order cannot be altered.

Figure B.1. Cylinders between two walls
입력 형식
The input consists of a single test case. The first line has an integer N (1 ≤ N ≤ 500), which is the number of cylinders. The second line has N positive integers at most 10,000. They are the radii of cylinders from one side to the other.
출력 형식
Print the distance between the two walls when they fully squeeze up the cylinders. The number should not contain an error greater than 0.0001.
예제 입력 1
2
10 10
예제 출력 1
40.00000000
예제 입력 2
2
4 12
예제 출력 2
29.85640646
예제 입력 3
5
1 10 1 10 1
예제 출력 3
40.00000000
예제 입력 4
3
1 1 1
예제 출력 4
6.00000000
예제 입력 5
2
5000 10000
예제 출력 5
29142.13562373
힌트
The following figures correspond to the Sample 1, 2, and 3.
![]() |
![]() |
![]() |
| Figure B.2. Sample 1 | Figure B.3. Sample 2 | Figure B.4. Sample 3 |



Comments