#D12835. Making Perimeter of the Convex Hull Shortest
Making Perimeter of the Convex Hull Shortest
Making Perimeter of the Convex Hull Shortest
Problem D Making Perimeter of the Convex Hull Shortest
The convex hull of a set of three or more planar points is, when not all of them are on one line, the convex polygon with the smallest area that has all the points of the set on its boundary or in its inside. Your task is, given positions of the points of a set, to find how much shorter the perimeter of the convex hull can be made by excluding two points from the set.
The figures below correspond to the three cases given as Sample Input 1 to 3. Encircled points are excluded to make the shortest convex hull depicted as thick dashed lines.
Sample Input 1 | Sample Input 2 | Sample Input 3 |
Input
The input consists of a single test case in the following format.
...
Here, is the number of points in the set satisfying . For each , () gives the coordinates of the position of the -th point in the set. and are integers between and , inclusive. All the points in the set are distinct, that is, or holds when . It is guaranteed that no single line goes through or more points in the set.
Output
Output the difference of the perimeter of the convex hull of the original set and the shortest of the perimeters of the convex hulls of the subsets with two points excluded from the original set. The output should not have an error greater than .
Sample Input 1
10 -53 62 -19 58 -11 11 -9 -22 45 -7 37 -39 47 -58 -2 41 -37 10 13 42
Sample Output 1
72.96316928
Sample Input 2
10 -53 62 -19 58 -11 11 -9 -22 45 -7 43 -47 47 -58 -2 41 -37 10 13 42
Sample Output 2
62.62947992
Sample Input 3
10 -53 62 -35 47 -11 11 -9 -22 45 -7 43 -47 47 -58 -2 41 -37 10 13 42
Sample Output 3
61.58166534
Example
Input
10 -53 62 -19 58 -11 11 -9 -22 45 -7 37 -39 47 -58 -2 41 -37 10 13 42
Output
72.96316928
inputFormat
Input 1 to 3. Encircled points are excluded to make the shortest convex hull depicted as thick dashed lines.
Sample Input 1 | Sample Input 2 | Sample Input 3 |
Input
The input consists of a single test case in the following format.
...
Here, is the number of points in the set satisfying . For each , () gives the coordinates of the position of the -th point in the set. and are integers between and , inclusive. All the points in the set are distinct, that is, or holds when . It is guaranteed that no single line goes through or more points in the set.
outputFormat
Output
Output the difference of the perimeter of the convex hull of the original set and the shortest of the perimeters of the convex hulls of the subsets with two points excluded from the original set. The output should not have an error greater than .
Sample Input 1
10 -53 62 -19 58 -11 11 -9 -22 45 -7 37 -39 47 -58 -2 41 -37 10 13 42
Sample Output 1
72.96316928
Sample Input 2
10 -53 62 -19 58 -11 11 -9 -22 45 -7 43 -47 47 -58 -2 41 -37 10 13 42
Sample Output 2
62.62947992
Sample Input 3
10 -53 62 -35 47 -11 11 -9 -22 45 -7 43 -47 47 -58 -2 41 -37 10 13 42
Sample Output 3
61.58166534
Example
Input
10 -53 62 -19 58 -11 11 -9 -22 45 -7 37 -39 47 -58 -2 41 -37 10 13 42
Output
72.96316928
样例
10
-53 62
-19 58
-11 11
-9 -22
45 -7
37 -39
47 -58
-2 41
-37 10
13 42
72.96316928