Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Robinson Crusoe

By Rajan_sust · Limits 1s, 512 MB

Robinson wants to be a mariner. But his father wants him to be a lawyer. But, if Robinson can solve the following problem, his father will grant his wish.

Suppose you are Robinson. You will be given n fractions. You have to arrange them in descending order. Can you solve the problem?


The first line contains a single integer n (1 ≤ n ≤ 1000) that denotes number of fractions. Each of the next n lines contains two integers denoting the numerator and denominator of the fractions.

The numerators and denominators will be in the range $ [1, 10^{17}]$.


Print n fractions in n lines in descending order. If two fractions are same, maintain the input order for printing.

Please refer to sample input/output section for better understanding.


10 2
15 3
24 4
24 4
10 2
15 3



    40% Solution Ratio

    Ashraful_jnuEarliest, 1M ago

    Ashraful_jnuFastest, 0.0s

    Ashraful_jnuLightest, 131 kB

    BruteforcekidShortest, 326B


    Login to submit