8149: Field Reduction

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

农夫约翰的 N 头奶牛分布在其二维农场的不同位置。

约翰想用一个长方形的围栏把所有的奶牛围起来,围栏的边需要平行于 x 轴和 y 轴。

在能够包含所有奶牛的情况下(处于围栏边界的奶牛也算包含在内),约翰希望围栏围起的面积尽可能小。

不幸的是,由于上个季度的牛奶产量很低,约翰的预算十分紧张。

因此,他希望建立一个更小的围栏,甚至为了实现这一目标,他愿意卖掉农场中的最多 3 头奶牛。

请帮助约翰计算,卖掉牛群中的最多三头奶牛以后,他可以用围栏围起来的最小面积(为剩下的奶牛建造尽可能小的围栏)。

对于这个问题,请将奶牛视为点,将围栏视为四个线段的集合(即,不要将奶牛视为“单位正方形”)。

注意,答案可以是零,例如,所有剩余的奶牛最终都站在同一条垂直或水平线上。

输入格式

第一行包含整数 N

接下来 N 行,每行包含两个整数 x,y,表示一头牛所在的位置坐标为 (x,y)

输出格式

输出卖掉牛群中的最多三头奶牛以后,约翰可以用围栏围起来的最小面积。

数据范围

5≤N≤50000,

1≤x,y≤40000


Farmer John's NN cows (5≤N≤50,000) are all located at distinct positions in his two-dimensional field. FJ wants to enclose all of the cows with a rectangular fence whose sides are parallel to the x and y axes, and he wants this fence to be as small as possible so that it contains every cow (cows on the boundary are allowed).

FJ is unfortunately on a tight budget due to low milk production last quarter. He would therefore like to build an even smaller fenced enclosure if possible, and he is willing to sell up to three cows from his herd to make this possible.

Please help FJ compute the smallest possible area he can enclose with his fence after removing up to three cows from his herd (and thereafter building the tightest enclosing fence for the remaining cows).

For this problem, please treat cows as points and the fence as a collection of four line segments (i.e., don't think of the cows as "unit squares"). Note that the answer can be zero, for example if all remaining cows end up standing in a common vertical or horizontal line.

输入格式

The first line of input contains N. The next N lines each contain two integers specifying the location of a cow. Cow locations are positive integers in the range 1…40,000.

输出格式

Write a single integer specifying the minimum area FJ can enclose with his fence after removing up to three carefully-chosen cows from his herd.

输入样例 复制

6
1 1
7 8
10 9
8 12
4 100
50 7

输出样例 复制

12