Under construction

Still being built. Things may change

Caravan Robbers

Time limit1sMemory limit128 MB

Summary
Given nested-free intervals, place equal-length disjoint subintervals inside them and output the maximum common length as an exact fraction.
Level

Hard8 of 10

Topics
Binary search, Greedy, Sorting, Math
Solved
No attempts yet

Problem

Long ago, in a faraway land, there were two great cities joined by the Great Caravan Road. Many robber gangs "worked" along that road.

By an old custom, the ii-th gang robbed every merchant who dared to travel between miles aia_i and bib_i of the Great Caravan Road. The custom was old but clever: there were no two distinct gangs ii and jj with ai≤aja_i \le a_j and bj≤bib_j \le b_i (that is, no gang's interval contained another's). Still, whenever two gangs' intervals overlapped, bloody fights sometimes broke out.

To end the wars, the gang leaders decided to reassign each gang a new interval so that:

  • all new intervals are pairwise non-overlapping (to avoid bloodshed),
  • each gang's new interval is a subinterval of its old one (to respect the old custom), and
  • all new intervals have the same length (to keep things fair).

Compute the maximum possible common length of the intervals after this redistribution.

Input

The first line contains nn (1≤n≤1000001 \le n \le 100000) — the number of gangs.

Each of the next nn lines contains two integers aia_i and bib_i (0≤ai<bi≤10000000 \le a_i < b_i \le 1000000), describing one gang's interval. The input satisfies the condition stated above: no gang's interval contains another's.

Output

Output the maximum possible common interval length, in miles, as an irreducible fraction p/qp/q.

Note

For the sample with gangs (2,6)(2, 6), (1,4)(1, 4), and (8,12)(8, 12), one optimal redistribution gives every gang an interval of length 5/25/2:

  • the first gang takes [7/2,6]=[3.5,6][7/2, 6] = [3.5, 6], a subinterval of its original (2,6)(2, 6);
  • the second gang takes [1,7/2]=[1,3.5][1, 7/2] = [1, 3.5], a subinterval of its original (1,4)(1, 4);
  • the third gang takes [8,21/2]=[8,10.5][8, 21/2] = [8, 10.5], a subinterval of its original (8,12)(8, 12).

Examples1

  1. Example 1

    Input
    3
    2 6
    1 4
    8 12
    
    Expected output
    5/2