Captain Latvia
Time limit1sMemory limit1024 MB
Choose left and right wall points so the triangle through (X,0) covers as many given enemy points as possible; output the maximum count.
- Level
Medium7 of 10
- Topics
- Geometry, Greedy, Sorting, Brute force
- Solved
- No attempts yet
Statement
Consider an infinitely long corridor drawn in the plane. Its floor (the bottom wall) is the segment from to . Its two side walls are the rays that start at and and extend upward (in the direction of increasing ). Thus the corridor is the set of all points with and .
There are enemies in the corridor. The -th enemy stands at the point , where and .
The hero stands at the point on the floor, where , and throws a shield without moving. The shield flies in a straight line to a point on one side wall, bounces to a point on the other side wall, and then flies straight back to the hero. Its trajectory is therefore a triangle whose three vertices are the hero's position , a point on the left wall, and a point on the right wall. Every enemy that lies on the boundary of this triangle (on any of its three edges) is knocked out.
The hero may aim freely: the two wall vertices may be placed anywhere on the walls, at any height . Find the maximum number of enemies that can be knocked out with a single throw.
Input
The first line contains two integers and — the length of the floor and the number of enemies. The second line contains one integer — the hero's -coordinate. Each of the next lines contains two space-separated integers and — the coordinates of the -th enemy.
Output
Print one integer — the maximum number of enemies that can be knocked out with a single throw.
Constraints
- All coordinates are integers.