QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 40

#14013. Radio Receiver

統計

You have a radio receiver and want to receive N messages. Each message is transmitted at a predetermined time measured in seconds since the epoch. Also each message is transmitted from a predetermined position representing the displacement in meters from the origin (you are in 1-dimensional space). Your radio is capable of receiving any message that is transmitted no farther than D meters from your current position, where Dis a nonnegative real number.

You can start at any position of your choice and move at the rate of at most one meter per second. The action of receiving a message itself takes no time. Your task is to find the smallest D that allows you to get all messages.

Input

The first line of input gives the number of test cases, C. C test cases follow. For each test case there will be:

  • One line containing the integer N, the number of messages.
  • N lines corresponding to the N messages where each of them contains 2 integers P and T separated by one space. P is the position where the message is transmitted from and T is the time when this message is transmitted (The messages will have distinct transmission times).

Output

For each test case, output one line containing "Case #x: ", where x is the number of the test case, followed by the minimum value D that allows you to get all messages. Answers with a relative or absolute error of at most 10-9 will be considered correct.

Limits

  • 1 ≤ C ≤ 100
  • 1 ≤ N ≤ 1000

Small Dataset (15 points)

  • 0 ≤ P ≤ 1000
  • 0 ≤ T ≤ 1000

Small Dataset (25 points)

  • 0 ≤ P ≤ 109
  • 0 ≤ T ≤ 109

Example

Input

3
3
7 2
20 3
0 11
2
6 5
6 3
4
5 3
2 1
9 4
7 2

Output

Case #1: 6
Case #2: 0
Case #3: 2.00

Here is one possible scenario with D = 6 for test case #1. Start at position 13 and time 2 to get message 0. Then walk to the right to position 14, arriving at time 3 to get message 1. Then walk left to position 6, arriving at time 11 to get message 2.

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.