This page is still under construction.

Parts of this page are still being built. What you see may change.

Intercepting Missiles

Time limit1sMemory limit128 MB

Summary
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 yy-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 xx-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 yy-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 xx-coordinates of all our missiles; during that time it may still be struck by other missiles.

Input

The first line contains an integer tt, the number of test cases. Each test case is preceded by a blank line.

Each test case begins with a line containing three integers mm, nn, and kk (0≤m,n,k≤3000 \le m, n, k \le 300): the number of bombers, the number of airplanes, and the number of missiles. The next line contains three integers vmv_m, vnv_n, and vkv_k (1≤vm,vn,vk≤100001 \le v_m, v_n, v_k \le 10000): the speeds of the bombers, the airplanes, and the missiles, respectively. Bombers and airplanes move to the right; missiles move straight up.

The next mm lines each contain two integers, the xx- and yy-coordinates of the head of a bomber at time zero. The following nn lines describe the airplanes in the same way. The last line contains kk integers, the xx-coordinates of the missiles ready to launch. All coordinates are nonnegative integers smaller than 1000010000.

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.

Examples3

  1. Example 1

    Input
    1
    
    2 1 3
    1 1 1
    0 100
    1 99
    2 50
    100 200 300
    
    Expected output
    Mission #1: 1 bomber(s) exploded
    
  2. Example 2

    Input
    1
    
    1 0 1
    1 1 1
    0 10
    100
    
    Expected output
    Mission #1: 1 bomber(s) exploded
    
  3. Example 3

    Input
    1
    
    3 0 3
    1 1 1
    0 10
    0 20
    0 30
    100 200 300
    
    Expected output
    Mission #1: 3 bomber(s) exploded