Split points by a vertical line that avoids all points, build the minimum-area enclosing convex hull of each side, and minimize the total area.
Hard8GeometrySortingDivide and conquerImplementationNo attempts yetTime limit2sMemory limit512 MBTwo organizations, the International Community for Preservation of Constructions (ICPC) and the Japanese Archaeologist Group (JAG), preserve ruins. Recently many ruins were found in a certain zone. The two organizations decided to share the preservation of the ruins by assigning some of the ruins to ICPC and the rest to JAG.
ICPC and JAG use the following rule for the assignment.
The question is where to draw the line. Each organization preserves its assigned ruins by building exactly one fence such that all of its assigned ruins lie in the region surrounded by the fence, and to save budget it makes that fence as short as possible. Maintaining the inside of a large surrounded region is expensive, so the two organizations want to minimize the total preservation cost, that is, the sum of the areas surrounded by the two fences.
Write a program that computes the minimum possible sum of the areas surrounded by the two fences over all valid positions of the line.
The input consists of a single test case.
N
x1 y1
...
xN yN
The first line contains an integer N (1≤N≤100,000), the number of ruins found. Each of the following N lines gives the location of one ruin: the i-th of them contains two integers xi and yi, meaning that the i-th ruin is xi east and yi north of a reference point in the zone. You may assume the following about the ruins.
Print the minimum total preservation cost, that is, the minimum sum of the areas surrounded by the two fences over all valid lines. The sum is always an integer or an integer plus 0.5. Print it rounded to the nearest integer, rounding a fractional part of exactly 0.5 up.