Red Points and Blue Points
Time limit1sMemory limit128 MB
Given red and blue points on a plane, find two parallel lines (avoiding all points, excluding all blue points from the strip) that maximize red points strictly between them.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search, Sorting
- Solved
- No attempts yet
Problem
There are red points and blue points on a coordinate plane. You will draw two parallel lines to protect red points that lie strictly between them. No blue point may lie between the two lines, and neither line may pass through any point.
It may be impossible to protect every red point. Find the maximum number of red points that can be protected by choosing two such parallel lines.
Input
The first line contains the number of points N. (1 ≤ N ≤ 1000)
Each of the next N lines contains a point's x-coordinate, y-coordinate, and color, separated by spaces. Each coordinate is an integer whose absolute value is less than 10^9, and the color is either R or B.
No three points are collinear.
Output
Print the maximum number of red points that can be protected by two parallel lines satisfying the conditions.