|
<p> |
|
Uh oh, the weather forecast predicts that a rainstorm will soon break out over the infinite, 1-dimensional number line you call home! |
|
</p> |
|
|
|
<p> |
|
The forecast is remarkably precise. In fact, it's known that exactly <strong>N</strong> raindrops will fall, with the <strong>i</strong>th drop striking the number line at position |
|
<strong>X<sub>i</sub></strong> exactly <strong>K<sub>i</sub></strong> seconds after the start of the storm. |
|
No two drops will strike the number line at exactly the same position and time. |
|
</p> |
|
|
|
<p> |
|
You'd like to stop as many of the drops as possible, but you don't exactly have an umbrella... so your boomerang will have to do. Your plan is as follows: |
|
</p> |
|
|
|
<p> |
|
<ol> |
|
<li> Stand at some (possibly non-integral) position A on the number line, and choose some other position B (A ≠ B). </li> |
|
<li> At some point in time, throw your boomerang from A to B. This point in time can be arbitrarily long before or after the start of the storm (the storm won't start for a while, so you have time to prepare). |
|
The boomerang will travel along your chosen line segment at a constant speed of S units per second. </li> |
|
<li> Make your boomerang spin in place at position B for some non-negative amount of time (which can be arbitrarily large). </li> |
|
<li> Have your boomerang travel back along the line segment from B to A at the same speed, and catch it as soon as it gets back to position A. </li> |
|
</ol> |
|
</p> |
|
|
|
<p> |
|
During the inclusive time interval from when you throw the boomerang to when you catch it again, if the boomerang is ever at exactly the same position as a raindrop at exactly the time that it strikes the number line, |
|
it will intercept it... just like an umbrella! What's the maximum number of raindrops you can intercept in this way with a single throw? |
|
</p> |
|
|
|
|
|
<h3>Input</h3> |
|
<p> |
|
Input begins with an integer <strong>T</strong>, the number of rainstorms. |
|
For each rainstorm, there is first a line containing the space-separated integers <strong>N</strong> and <strong>S</strong>. |
|
Then, <strong>N</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers |
|
<strong>X<sub>i</sub></strong> and <strong>K<sub>i</sub></strong>. |
|
</p> |
|
|
|
|
|
<h3>Output</h3> |
|
<p> |
|
For the <strong>i</strong>th rainstorm, print a line containing "Case #<strong>i</strong>: " followed by |
|
the maximum number of raindrops you can stop. |
|
</p> |
|
|
|
|
|
<h3>Constraints</h3> |
|
<p> |
|
1 ≤ <strong>T</strong> ≤ 50 <br /> |
|
1 ≤ <strong>N</strong> ≤ 100,000 <br /> |
|
1 ≤ <strong>S</strong> ≤ 1,000,000,000 <br /> |
|
0 ≤ <strong>X<sub>i</sub></strong>, <strong>K<sub>i</sub></strong> ≤ 1,000,000,000 <br> |
|
</p> |
|
|
|
|
|
<h3>Explanation of Sample</h3> |
|
<p> |
|
In the first rainstorm, one solution is to stand at X = 99 and let your boomerang spin at X = 100 until it intercepts all three raindrops that will fall at that position. |
|
|
|
In the second rainstorm, one solution is to stand at X = 50 and throw your boomerang towards X = 100 as soon as the first raindrop hits it. |
|
If you recall your boomerang as soon as it reaches X = 100, it will hit the second raindrop and be back just in time to hit the third. |
|
</p> |
|
|