This page is still under construction.

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

Fakes and Shidget

Time limit2sMemory limit512 MB

Summary
Each of n characters offers two quests with given times and rewards; find the maximum long-run gold per minute when the character each round is chosen uniformly at random.
Level

Hard8 of 10

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

Problem

Pavel loves the game Fakes and Shidget very much. The game literally consists of the following process. The player uniformly randomly meets one of nn characters. Every character offers the player to choose one of two quests. The first quest of the ii-th character requires aia_i minutes to complete and brings bib_i gold, and the second quest requires cic_i minutes and brings did_i gold. The player chooses one of these quests, completes it and immediately meets another random character, and so on.

Pavel will play this game infinitely long. How fast can he earn gold if he will play optimally?

More formally, let tt is the time Pavel plays this game, and g(t)g(t) is the amount of gold he earns for the time tt. You should find the limit lim⁡t→∞g(t)t\lim \limits_{t \to \infty} \frac{g\left(t\right)}{t}.

Input

The first line contains an integer nn (1≤n≤2000001 \le n \le 200000) --- the number of characters in the game.

Each of the next nn lines contains four integers aia_i, bib_i, cic_i and did_i (1≤ai,bi,ci,di≤1091 \le a_i, b_i, c_i, d_i \le 10^{9}) --- the duration of the first quest, the reward for the first quest, the duration of the second quest, the reward for the second quest of the ii-th character.

Output

Output one floating point number --- the maximal possible speed of earning gold.

The absolute or relative error of the answer shouldn't exceed 10−910^{-9}.

Examples2

  1. Example 1

    Input
    2
    1 10 10 70
    1 1 10 20
    
    Expected output
    6.454545454545455
    
  2. Example 2

    Input
    2
    1 20 100 100
    2 1 2 1
    
    Expected output
    7.000000000000000