Ghost Busters
Time limit1sMemory limit128 MB
A ray from the origin inside the octant X,Y,Z >= 0 must be aimed to graze (touch) as many spheres as possible; report the maximum count.
- Level
Medium7 of 10
- Topics
- Geometry, Math, Brute force, Implementation
- Solved
- No attempts yet
Problem

The Ghost Busters team has upgraded their Ecto-1 with a powerful proton gun and an automatic targeting system, and you have been hired to write a prototype for the targeting software.
Each ghost is detected as a floating sphere, given by the coordinates of its center and its radius. The proton gun fires from the origin in any direction inside the octant . It emits a single ray that travels in a straight line from the origin; even a graze from this ray destroys a ghost, and one ray can destroy an unlimited number of ghosts lying along its path.
Determine the maximum number of ghosts that can be destroyed with a single shot fired from the origin.
Input
The first line contains the number of detected ghosts ().
Each of the next lines describes one ghost with four integers , , , separated by spaces, where is the center and is the radius. It is guaranteed that and .
Ghosts may overlap, be contained in one another, or coincide.
Output
Print a single integer: the maximum number of ghosts that can be destroyed with one shot.