Field Reduction
Time limit2sMemory limit512 MB
Remove up to three of N points so the axis-aligned bounding rectangle of the rest has the smallest possible area.
- Level
Medium6 of 10
- Topics
- Brute force, Geometry
- Solved
- No attempts yet
Problem
Farmer John has cows () standing at distinct positions of a two dimensional field. He wants to enclose all of them with a rectangular fence whose sides are parallel to the and axes, and he wants that rectangle to be as small as possible while it still contains every cow. A cow standing on the boundary counts as enclosed.
Milk production was low last quarter, so the budget is tight. If selling cows makes the fence smaller, John is willing to sell up to three of them.
Compute the smallest area John can enclose after he removes at most three cows and then builds the tightest rectangle around the ones that remain.
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 stands on one vertical line or one horizontal line.
Input
The first line contains . Each of the next lines contains two integers, the and coordinate of one cow. Every coordinate is an integer between and , and no two cows stand at the same position.
Output
Print one integer, the minimum area John can enclose after removing at most three carefully chosen cows.