結果

問題 No.750 Frac #1
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2019-02-19 20:54:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 152 ms / 1,000 ms
コード長 1,163 bytes
コンパイル時間 2,458 ms
コンパイル使用メモリ 80,144 KB
実行使用メモリ 42,632 KB
最終ジャッジ日時 2024-04-20 21:15:01
合計ジャッジ時間 7,671 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
41,936 KB
testcase_01 AC 122 ms
42,084 KB
testcase_02 AC 129 ms
42,332 KB
testcase_03 AC 130 ms
42,616 KB
testcase_04 AC 120 ms
42,352 KB
testcase_05 AC 136 ms
42,576 KB
testcase_06 AC 126 ms
42,212 KB
testcase_07 AC 122 ms
42,144 KB
testcase_08 AC 135 ms
42,548 KB
testcase_09 AC 132 ms
42,364 KB
testcase_10 AC 125 ms
41,860 KB
testcase_11 AC 119 ms
42,148 KB
testcase_12 AC 136 ms
41,888 KB
testcase_13 AC 123 ms
41,836 KB
testcase_14 AC 125 ms
42,036 KB
testcase_15 AC 144 ms
42,312 KB
testcase_16 AC 135 ms
42,020 KB
testcase_17 AC 143 ms
42,628 KB
testcase_18 AC 140 ms
42,580 KB
testcase_19 AC 124 ms
41,904 KB
testcase_20 AC 127 ms
42,012 KB
testcase_21 AC 129 ms
41,940 KB
testcase_22 AC 142 ms
42,388 KB
testcase_23 AC 129 ms
42,176 KB
testcase_24 AC 144 ms
42,532 KB
testcase_25 AC 119 ms
41,968 KB
testcase_26 AC 152 ms
42,632 KB
testcase_27 AC 145 ms
41,864 KB
testcase_28 AC 140 ms
42,504 KB
testcase_29 AC 141 ms
42,332 KB
testcase_30 AC 129 ms
41,932 KB
testcase_31 AC 141 ms
42,368 KB
testcase_32 AC 135 ms
42,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Decimal> list = new ArrayList<>();
        for(int i=0; i<n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            list.add(new Decimal(a,b));
        }
        Collections.sort(list, new DecimalComparator());
        
        for(int i=0; i<n; i++) {
            System.out.println( list.get(i).getNumerator() + " " + list.get(i).getDenominator() );
        }
    }
}

class Decimal {
    private int numerator;
    private int denominator;
    
    public Decimal(int numerator, int denominator) {
        this.numerator = numerator;
        this.denominator = denominator;
    }
    
    public int getNumerator() {
        return numerator;
    }
    
    public int getDenominator() {
        return denominator;
    }
}

class DecimalComparator implements Comparator<Decimal> {
    public int compare(Decimal d1, Decimal d2) {
        return d1.getDenominator() * d2.getNumerator() - d2.getDenominator() * d1.getNumerator();
    }
}
0