Laser
Time limit3sMemory limit512 MB
Choose up to K rays from the origin to hit the most first-quadrant segments, with no segment hit by two rays.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Geometry, Intervals, Sorting
- Solved
- No attempts yet
Problem
Jaehyun built a game a while back. It is called "Yoo Jaemin", and the hero of the game is Yoo Jaemin.
Yoo Jaemin fires laser beams from the origin . A beam is a ray that starts at the origin and travels outward in whatever direction the player picks. The goal is to hit as many of the segments on the coordinate plane as possible. Yoo Jaemin can fire the beam at most times, and a beam that only passes through an endpoint of a segment still counts as a hit.
Jaehyun left one case unhandled while writing the game: hitting a segment that has already been hit crashes the program. He panicked at first, then decided a game with that rule sounds fun anyway, so he wants to play it optimally. Find the largest number of segments he can hit without ever hitting the same segment twice.
Input
The first line contains and . (, )
Each of the next lines contains one segment as , , , . () The segment joins the point and the point .
Output
Print the largest number of segments that can be hit with at most laser beams, under the condition that a segment already hit is never hit again.
Hint
