This page is still under construction.

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

Protecting the Vegetables

Time limit2sMemory limit128 MB

Summary
Find the minimum-perimeter rectangle of any orientation that encloses all given points.
Level

Medium7 of 10

Topics
Geometry, Sorting, Two pointers
Solved
No attempts yet

Problem

Sanggeun steals Seonyeong's vegetables. To stop him, Seonyeong decided to surround every vegetable with one fence. The price of a fence is proportional to its length, so she wants the shortest perimeter she can get. For reasons nobody understands, the fence can only be built in the shape of a rectangle.

Vegetables have no size and are drawn as points in the plane. Find the rectangle of minimum perimeter that holds every vegetable inside it or on its boundary.

Input

The input consists of several test cases. The first line of each test case has the number of vegetables NN (3≤N≤10 0003 \le N \le 10\,000). Each of the next NN lines has two integers XiX_i and YiY_i (0≤Xi,Yi≤10 0000 \le X_i, Y_i \le 10\,000), the coordinates of one vegetable. No two vegetables share the same coordinates, and the vegetables of one test case never all lie on a single straight line.

The input runs to the end of the file.

Output

For each test case, print the minimum perimeter of the fence on a line of its own. The sides of the fence do not have to be parallel to the coordinate axes.

Round the perimeter at the seventh digit after the decimal point and print exactly six digits after the decimal point. A perimeter of exactly 44 is printed as 4.000000. No input places the answer on a rounding boundary.

Examples1

  1. Example 1

    Input
    3
    0 0
    1 0
    0 1
    3
    10 0
    0 10
    4 4
    4
    1 0
    0 1
    2 1
    1 2
    
    Expected output
    4.000000
    31.112698
    5.656854