After the Contest: Balloons

Time limit1sMemory limit128 MB

Summary
Simulate balloons inflated left to right on a line, each stopping at its max radius or when it touches an earlier balloon, and output the final radii efficiently.
Level

Medium7 of 10

Topics
Binary search, Geometry, Stack
Solved
No attempts yet

Problem

After finishing the preparations for CEOI 2011, you feel like throwing a party. Actually, more than a party, you want to blow up balloons. There are nn perfectly spherical balloons lying on the ground.

They have not been inflated yet, so each balloon starts with radius 00. The ii-th balloon is fixed at coordinate xix_i; it can neither move nor float away. The balloons are inflated one by one from left to right. Each balloon grows until it reaches its maximum radius rir_i, or until it touches another balloon that was inflated earlier.

Figure 1: all balloons of the example after being inflated.

Determine the final radius of every balloon.

Input

The first line contains the number of balloons nn (1≤n≤200 0001 \le n \le 200\,000).

Each of the next nn lines describes one balloon: the ii-th of these lines contains two integers xix_i and rir_i separated by a space. Here xix_i is the coordinate where the balloon sits (0≤xi≤1090 \le x_i \le 10^9) and rir_i is the maximum radius that balloon may reach (1≤ri≤1091 \le r_i \le 10^9). The balloons are given from left to right and the coordinates are strictly increasing, i.e. x1<x2<⋯<xnx_1 < x_2 < \dots < x_n.

Output

Print nn lines. The ii-th line must contain the final radius of the ii-th balloon, rounded to exactly 33 decimal places.

Examples2

  1. Example 1

    Input
    3
    0 9
    8 1
    13 7
    
    Expected output
    9.000
    1.000
    4.694
    
  2. Example 2

    Input
    2
    0 10
    6 10
    
    Expected output
    10.000
    0.900