Farmer John has N cows (5≤N≤50000) 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 x and y 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.