Field Reduction
InterviewTime limit2sMemory limit512 MB
You remove one of N points to minimize the axis-aligned bounding box area of the rest.
- Level
Medium5 of 10
- Topics
- Brute force, Geometry
- Solved
- No attempts yet
Problem
Farmer John's cows () stand at distinct positions in his two-dimensional field. John wants to enclose every cow with a rectangular fence whose sides are parallel to the x and y axes, and he wants the smallest fence that contains all of them. A cow standing on the boundary counts as enclosed.
Milk production was low last quarter, so the budget is tight. John is willing to sell one cow if that lets him build a smaller fence.
Compute the smallest area John can enclose after removing one cow of his choice and then building the tightest rectangle around the remaining cows.
In this problem a cow is a point and the fence is four line segments, so do not think of a cow as a unit square. The answer can be 0, for example when every remaining cow ends up on one vertical line or one horizontal line. is fairly large, so pick an approach that finishes inside the time limit.
Input
The first line contains . Each of the next lines contains two integers giving the position of one cow. Coordinates are integers between 1 and 40000.
Output
Print a single integer, the minimum area John can enclose after removing one carefully chosen cow.