The locations of Farmer John's N cows (1 <= N <= 500) are described by distinct points in the 2D plane. The cows belong to two breeds: Holsteins and Guernseys. Farmer John wants to build a rectangular fence with sides parallel to the coordinate axes enclosing only Holsteins, with no Guernseys (a cow counts as enclosed even if it is on the boundary). Among all such fences, he wants to enclose the maximum number of Holsteins, and among all these, a fence of minimum possible area. Please determine this area. A fence of zero width or height is allowable.
Input
Line 1: N.
Each of the next N lines describes a cow with two integers and a character: a point (x,y) (0 <= x,y <= 1000) and the breed H or G. No two cows are at the same point, and there is always at least one Holstein.
Output
Print two integers: the maximum number of Holsteins that can be enclosed by a fence containing no Guernseys, and the minimum area enclosed by such a fence.
Example 1
5 1 1 H 2 2 H 3 3 G 4 4 H 6 6 H
2 1
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.