結果

問題 No.750 Frac #1
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2019-02-19 20:54:44
言語 Java19
(openjdk 21)
結果
AC  
実行時間 165 ms / 1,000 ms
コード長 1,163 bytes
コンパイル時間 2,469 ms
コンパイル使用メモリ 81,024 KB
実行使用メモリ 57,192 KB
最終ジャッジ日時 2023-08-02 21:13:15
合計ジャッジ時間 9,542 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
56,868 KB
testcase_01 AC 157 ms
56,884 KB
testcase_02 AC 159 ms
56,724 KB
testcase_03 AC 157 ms
56,644 KB
testcase_04 AC 156 ms
56,920 KB
testcase_05 AC 159 ms
56,916 KB
testcase_06 AC 158 ms
56,784 KB
testcase_07 AC 157 ms
56,508 KB
testcase_08 AC 158 ms
56,704 KB
testcase_09 AC 159 ms
56,664 KB
testcase_10 AC 158 ms
56,804 KB
testcase_11 AC 161 ms
56,852 KB
testcase_12 AC 165 ms
56,628 KB
testcase_13 AC 156 ms
56,844 KB
testcase_14 AC 157 ms
56,872 KB
testcase_15 AC 155 ms
56,468 KB
testcase_16 AC 157 ms
56,596 KB
testcase_17 AC 159 ms
56,736 KB
testcase_18 AC 155 ms
56,508 KB
testcase_19 AC 155 ms
56,440 KB
testcase_20 AC 160 ms
57,008 KB
testcase_21 AC 155 ms
57,184 KB
testcase_22 AC 156 ms
56,680 KB
testcase_23 AC 156 ms
56,500 KB
testcase_24 AC 156 ms
57,192 KB
testcase_25 AC 156 ms
56,848 KB
testcase_26 AC 157 ms
56,684 KB
testcase_27 AC 156 ms
56,712 KB
testcase_28 AC 155 ms
57,036 KB
testcase_29 AC 157 ms
56,496 KB
testcase_30 AC 157 ms
56,636 KB
testcase_31 AC 158 ms
56,620 KB
testcase_32 AC 157 ms
56,688 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