This page is still under construction.

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

Chasing the Cheetahs

Time limit3sMemory limit256 MB

Summary
Given start times and speeds from one spot, find the smallest gap between the first and last cheetah at any time after all have started.
Level

Medium6 of 10

Topics
Binary search, Math
Solved
No attempts yet

Problem

A film crew is shooting a documentary about animal speed and wants several cheetahs sprinting at full pace in a single shot. One running cheetah has been filmed many times already, so this time the crew is after a pack.

Herding every cheetah into one box and opening it all at once is too dangerous to try. Each cheetah gets its own start box instead, and the slower ones are released first. After a while the faster cheetahs overtake the slower ones and the pack draws together as tightly as it ever will. The crew wants the length of the pack at that moment.

All start boxes stand at the same place. Cheetah kk is released at time tkt_k and runs at the constant speed vkv_k from that moment on. At time TT the length of the pack is the distance between the leading cheetah and the trailing one.

The length is measured only once every cheetah has started, that is at T≥max⁡(t1,…,tN)T \ge \max(t_1, \dots, t_N). The track is long enough that the shortest moment arrives before the leading cheetah reaches the finish line. Find the minimum length of the pack.

Input

The input holds several test cases. The first line of a test case contains the number of cheetahs NN (1≤N≤1000001 \le N \le 100000). Each of the next NN lines contains two integers tkt_k and vkv_k separated by a space (1≤tk,vk≤999991 \le t_k, v_k \le 99999), the start time and the speed of cheetah kk.

The last line of the input contains a single 00. That line is not a test case.

Output

For each test case print the minimum length of the pack on its own line. Round the value to three digits after the decimal point and print all three digits, trailing zeros included.

Examples2

  1. Example 1

    Input
    2
    1 1
    1 1
    2
    1 99999
    99999 99999
    3
    1 1
    3 2
    4 3
    0
    
    Expected output
    0.000
    9999700002.000
    0.500
    
  2. Example 2

    Input
    2
    1 2
    5 4
    0
    
    Expected output
    0.000