Radio Receiver (Small)
InterviewTime limit5sMemory limit512 MB
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 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 metres from your current position, where 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 that lets you receive every message.
Input
The first line contains the number of test cases . Each test case is given as follows.
- One line with the number of messages .
- lines with the position and the transmission time of a message, separated by one space. Within one test case all transmission times are different.
Limits
Output
For each test case, print one line in the form Case #x: D, where is the test case number starting at 1 and 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, 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.