Holstein Fence
Time limit1sMemory limit256 MB
Enclose the most Holsteins in an axis-aligned rectangle with no Guernsey inside, breaking ties by smallest area.
- Level
Medium6 of 10
- Topics
- Brute force, Sorting, Geometry
- Solved
- No attempts yet
Problem
There are cows () standing on the plane at distinct points. Each cow is either a Holstein or a Guernsey.
The farmer wants to build a rectangular fence with sides parallel to the coordinate axes so that it encloses only Holsteins and no Guernsey at all. A cow on the boundary of the fence counts as enclosed.
Among all such fences, pick the one that encloses the most Holsteins, and among those, pick the one with the smallest area. Report the number of enclosed Holsteins and that area. A fence of width or height is allowed.
Input
The first line contains .
Each of the next lines contains two integers , () and one character. is where the cow stands, and the character gives the breed: H for a Holstein, G for a Guernsey.
No two cows stand at the same point, and at least one cow is a Holstein.
Output
On the first line, print the maximum number of Holsteins that a fence enclosing no Guernsey can enclose.
On the second line, print the smallest area among those fences.