This page is still under construction.

Parts of this page are still being built. What you see may change.

Making the Perimeter of the Convex Hull Shortest

Time limit2sMemory limit512 MB

Summary
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.

Sample 1Sample 2Sample 3

Input

The input consists of a single test case in the following format.

n
x1 y1
.
.
.
xn yn

Here, nn is the number of points in the set, with 5≤n≤20005 \le n \le 2000. For each ii, (xi,yi)(x_i, y_i) gives the coordinates of the ii-th point of the set. xix_i and yiy_i are integers between −106-10^6 and 10610^6, inclusive. All the points of the set are distinct, that is, xj≠xkx_j \ne x_k or yj≠yky_j \ne y_k holds when j≠kj \ne k. No single line passes through n−2n - 2 or more points of the set.

Output

Let PP be the perimeter of the convex hull of the whole set, and let QQ be the smallest perimeter among the convex hulls of the sets obtained by excluding two points. Print P−QP - Q with exactly six digits after the decimal point.

Examples3

  1. Example 1

    Input
    10
    -53 62
    -19 58
    -11 11
    -9 -22
    45 -7
    37 -39
    47 -58
    -2 41
    -37 10
    13 42
    
    Expected output
    72.963169
    
  2. Example 2

    Input
    10
    -53 62
    -19 58
    -11 11
    -9 -22
    45 -7
    43 -47
    47 -58
    -2 41
    -37 10
    13 42
    
    Expected output
    62.629480
    
  3. Example 3

    Input
    10
    -53 62
    -35 47
    -11 11
    -9 -22
    45 -7
    43 -47
    47 -58
    -2 41
    -37 10
    13 42
    
    Expected output
    61.581665