Making the Perimeter of the Convex Hull Shortest
Time limit2sMemory limit512 MB
Given n points, find the largest decrease in convex hull perimeter achievable by removing exactly two of the points.
- Level
Hard8 of 10
- Topics
- Geometry, Sorting, Brute force, Implementation
- Solved
- No attempts yet
Problem
The convex hull of a set of three or more points in the plane, when the points do not all lie on a single line, is the convex polygon of smallest area that holds every point of the set on its boundary or inside it.
You are given the positions of the points of a set. Find how much shorter the perimeter of the convex hull becomes when two points are excluded from the set. Exactly two points are excluded, and you choose which two.
The figures below correspond to the three sample cases. The circled points are the ones excluded to produce the shortest convex hull, drawn with thick dashed lines.
Input
The input consists of a single test case in the following format.
n
x1 y1
.
.
.
xn yn
Here, is the number of points in the set, with . For each , gives the coordinates of the -th point of the set. and are integers between and , inclusive. All the points of the set are distinct, that is, or holds when . No single line passes through or more points of the set.
Output
Let be the perimeter of the convex hull of the whole set, and let be the smallest perimeter among the convex hulls of the sets obtained by excluding two points. Print with exactly six digits after the decimal point.


