Smallest Rectangle
Time limit2sMemory limit128 MB
Find the minimum area axis-aligned rectangle with integer coordinates whose strict interior contains at least half of N given points.
- Level
Medium6 of 10
- Topics
- Geometry, Brute force, Sorting, Array
- Solved
- No attempts yet
Problem
Hyunsoo placed N points on a coordinate plane. Every point has nonnegative integer coordinates.
He wants to draw one rectangle whose four vertices all have integer coordinates and whose sides are parallel to the x-axis or the y-axis. The interior of the rectangle must contain at least N/2 of the given points. A point on an edge of the rectangle is not considered to be inside it.
Find the minimum possible area of a rectangle that satisfies these conditions.
Input
The first line contains N, the number of points. N is an even positive integer no greater than 100.
Each of the next N lines contains two integers x and y, the coordinates of one point. Each coordinate is an integer between 0 and 10,000 inclusive. All given points are distinct.
Output
Print the minimum area of a rectangle satisfying the conditions.
Hint
For the first visible test case, one valid rectangle has vertices (9, 4), (9, 6), (14, 4), and (14, 6).