Field Reduction (Bronze)#10570

Field Reduction (Bronze)

1 секунда
128 мегабајти
Средно

Farmer John's cows are all located at distinct positions in his two-dimensional field. FJ wants to enclose all of his cows with a rectangular fence whose sides are parallel to the - and -axes. He wants the fence to be as small as possible while still containing every cow, with cows on the boundary allowed.

Unfortunately, FJ is on a tight budget due to low milk production last quarter. He would therefore like to make the enclosure even smaller if possible, and he is willing to sell one cow from his herd to achieve this.

Please help FJ determine the minimum possible area he can enclose with his fence after removing one cow from his herd and then building the smallest possible enclosing rectangle around the remaining n - 1 cows.

For this problem, treat cows as points and the fence as a collection of four line segments (that is, do not think of the cows as "unit squares"). Note that the answer can be zero; for example, this occurs if all remaining cows lie on a common vertical or horizontal line.

Finally, since can be quite large, you may need to be careful about your approach to ensure that your program runs efficiently enough.

Влез

The first line contains an integer n~(3 \le n \le 50000). The next lines each contain two integers specifying the location of a cow. Cow locations are positive integers in the range from to .

Излез

Print one integer representing the minimum area FJ can enclose with his fence after removing one carefully chosen cow.

Примери

Пример 1

Loading
Loading