Under construction

Still being built. Things may change

Nikanor Loves Games

Time limit1sMemory limit512 MB

Summary
Choose positive integers a and b for one coin, paying a*b, to maximize expected winnings across n friends whose two-sided coins are known, where ties go to Nikanor.
Level

Hard8 of 10

Topics
Math, Geometry, Sorting, Brute force
Solved
No attempts yet

Problem

Nikanor spends all his free time on games. Because of this, he gets bad marks at the university, but that's another story. He also likes gambling. In this problem, we consider the modification of the game called "Orlyanka". There are two players, and each of them has his own coin. Each of the two sides of a coin contains an integer. Players toss their coins, and the winner is the one with the highest number. We can assume that for each coin the probabilities of coming up both sides are equal.

Tonight Nikanor is playing this game with his friends. Nikanor has nn friends, and he will play with each of them for a bet of xix_i rubles. Fortunately, Nikanor knows that his ii-th friend has a coin with the numbers aia_i and bib_i. If Nikanor wins against his friend, he will receive xix_i rubles. Otherwise, he will pay xix_i rubles to his friend. If Nikanor and his friend dropped the same value, Nikanor is declared the winner.

Now Nikanor is going to go to the store and buy one coin for all games to maximize his expected profit, taking the coin cost into account. In this shop, a coin with the numbers aa and bb costs a⋅ba \cdot b rubles. Nikanor can buy any coin with positive integers.

It's so hard for Nikanor to make the right decision... Nikanor asks you to help him choose a coin so that the expected profit is as high as possible.

Input

The first line contains one integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) denoting the number of friends.

Each of the following nn lines contains three integers aia_i, bib_i, and xix_i (1≤ai,bi,xi≤1091 \le a_i, b_i, x_i \le 10^{9}) representing the numbers on ii-th friend's coin and ii-th bet in rubles.

Output

Print a single integer --- the maximum expected profit.

Your answer will be considered correct if its absolute or relative error does not exceed 10−610^{-6}.

Formally, let your answer be aa, and the jury's answer be bb. Your answer will be accepted if and only if ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{|a-b|}{\max(1,|b|)} \le 10^{-6}.

Examples2

  1. Example 1

    Input
    2
    1 4 15
    3 5 10
    
    Expected output
    2.5000000000
    
  2. Example 2

    Input
    1
    2 2 8
    
    Expected output
    4.0000000000