Under construction

Still being built. Things may change

LED

Time limit1.3sMemory limit512 MB

Summary
Given n voltage and intensity pairs, the task finds a two-step step function that minimizes the maximum absolute error and prints that minimum error.
Level

Hard8 of 10

Topics
Binary search, Greedy, Sorting, Sliding window
Solved
No attempts yet

Problem

A light-emitting diode (LED) is a semiconductor light source that emits light when an electric current with a voltage higher than a threshold is applied to its leads. ACM R&D recently reported that they have successfully developed a new LED, called ACMOLED. The intensity of light from an ACMOLED changes in two steps as the voltage increases, as shown in the graph below.

An ACMOLED does not emit light for voltages from 0 to V1V_1. It emits light with intensity L1≥0L_1 \ge 0 when the voltage reaches the first threshold V1V_1, and light with intensity L2≥L1L_2 \ge L_1 when the voltage reaches the second threshold V2V_2. Formally, let F(v)F(v) be the function that maps voltage vv to the light intensity. For real numbers L1L_1, L2L_2, V1V_1, and V2V_2 with 0≤L1≤L20 \le L_1 \le L_2 and 0<V1<V20 < V_1 < V_2:

F(v)={0if 0≤v<V1L1if V1≤v<V2L2if v≥V2F(v) = \begin{cases} 0 & \text{if } 0 \le v < V_1 \\ L_1 & \text{if } V_1 \le v < V_2 \\ L_2 & \text{if } v \ge V_2 \end{cases}

ACM R&D does not know the exact values of V1V_1, V2V_2, L1L_1, and L2L_2. They plan to estimate these four values through repeated experiments. Each experiment applies a current at a chosen voltage and observes the light intensity. After nn experiments, the data are nn tuples (v1,l1),(v2,l2),…,(vn,ln)(v_1, l_1), (v_2, l_2), \ldots, (v_n, l_n), where lil_i is the observed intensity at voltage viv_i. The observing device is imprecise, so the data may contain errors. ACM R&D wants the estimated intensity function FF that minimizes the error function

error(F)=max⁡1≤i≤n∣li−F(vi)∣\text{error}(F) = \max_{1 \le i \le n} \left| l_i - F(v_i) \right|

Write a program that finds such an FF and outputs the value of error(F)\text{error}(F).

Input

The first line contains an integer nn (1≤n≤300,0001 \le n \le 300{,}000), the number of tuples. Each of the following nn lines contains two integers viv_i and lil_i (0≤vi,li≤1090 \le v_i, l_i \le 10^9). No two tuples have the same viv_i.

Output

Print exactly one line containing one real number, the minimum value of error(F)\text{error}(F), rounded to the first decimal place.

Examples2

  1. Example 1

    Input
    5
    0 0
    2 1
    3 5
    6 7
    7 11
    
    Expected output
    1.0
    
  2. Example 2

    Input
    10
    5 9
    8 9
    0 0
    23 18
    26 18
    2 0
    3 0
    13 9
    18 9
    21 18
    
    Expected output
    0.0