Under construction

Still being built. Things may change

Radio Receiver (Small)

Interview

Time limit5sMemory limit512 MB

Summary
Choose a walking path at speed at most one so every timed message on a line is within the smallest possible reception distance.
Level

Medium6 of 10

Topics
Binary search, Intervals, Sorting
Solved
No attempts yet

Problem

You have one radio receiver and you want to receive NN messages. Each message is transmitted at a fixed time from a fixed position. The time is measured in seconds from a reference moment, and the position is the distance from the origin in metres. You stand on a one dimensional line. The receiver picks up every message transmitted no farther than DD metres from your current position, where DD is a nonnegative real number.

You may start at any position you like, and you move at a rate of at most one metre per second. Receiving a message takes no time. Find the smallest DD that lets you receive every message.

Input

The first line contains the number of test cases CC. Each test case is given as follows.

  • One line with the number of messages NN.
  • NN lines with the position PP and the transmission time TT of a message, separated by one space. Within one test case all transmission times are different.

Limits

  • 1≤C≤1001 \le C \le 100
  • 1≤N≤10001 \le N \le 1000
  • 0≤P≤10000 \le P \le 1000
  • 0≤T≤10000 \le T \le 1000

Output

For each test case, print one line in the form Case #x: D, where xx is the test case number starting at 1 and DD is the smallest value that lets you receive every message. The answer is always a multiple of 0.5, so print it with exactly one digit after the decimal point. Write an answer of 6 as 6.0 and an answer of 2.5 as 2.5.

Hint

In the first test case of the first example, D=6D = 6 is enough. Stand at position 13 at time 2 to receive the first message, walk right to position 14 and arrive at time 3 for the second message, then walk left to position 6 and arrive at time 11 for the third message.

Examples2

  1. Example 1

    Input
    3
    3
    7 2
    20 3
    0 11
    2
    6 5
    6 3
    4
    5 3
    2 1
    9 4
    7 2
    
    Expected output
    Case #1: 6.0
    Case #2: 0.0
    Case #3: 2.0
    
  2. Example 2

    Input
    2
    1
    500 0
    2
    42 7
    42 100
    
    Expected output
    Case #1: 0.0
    Case #2: 0.0