Intercepting Missiles
Time limit1sMemory limit128 MB
Given moving bombers and passenger planes plus fixed missile launchers, find the maximum number of bombers that can be shot down without hitting any passenger plane.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search, Sorting, Greedy
- Solved
- No attempts yet
Problem
Our country is under attack. Enemy bombers are flying toward the capital to destroy it. To defend the capital we have several missiles that can be launched to hit the enemy bombers before they arrive. Unfortunately, there are also passenger airplanes in the sky, and we must never hit them.
We model the world as a flat, two-dimensional plane. Every bomber and every passenger airplane flies horizontally to the right at a fixed altitude, so a target's -coordinate never changes. All bombers share one common speed, all airplanes share one common speed, and all missiles share one common speed. Each missile sits on the ground and, once launched, travels straight up without changing its -coordinate. We know the position of every bomber, every airplane, and every missile at time zero.
Given this information, determine the maximum number of bombers that can be hit by our missiles without any passenger airplane being hit.
Assumptions:
- The -coordinates of the bombers and airplanes are distinct positive integers.
- Each bomber and each airplane has unit length; each missile is a single point with no length.
- A missile may be launched at time zero or at any later time.
- The moment a missile reaches, or just touches the edge of, a target in the sky, the missile explodes. A bomber that is hit keeps moving normally and only explodes after it has passed the -coordinates of all our missiles; during that time it may still be struck by other missiles.
Input
The first line contains an integer , the number of test cases. Each test case is preceded by a blank line.
Each test case begins with a line containing three integers , , and (): the number of bombers, the number of airplanes, and the number of missiles. The next line contains three integers , , and (): the speeds of the bombers, the airplanes, and the missiles, respectively. Bombers and airplanes move to the right; missiles move straight up.
The next lines each contain two integers, the - and -coordinates of the head of a bomber at time zero. The following lines describe the airplanes in the same way. The last line contains integers, the -coordinates of the missiles ready to launch. All coordinates are nonnegative integers smaller than .
Output
For each test case, output a single line in the form:
Mission #i: X bomber(s) exploded
where i is the 1-based index of the test case and X is the maximum number of bombers that can be hit while no passenger airplane is hit.