結果

問題 No.750 Frac #1
ユーザー tentententen
提出日時 2020-12-09 18:44:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 166 ms / 1,000 ms
コード長 946 bytes
コンパイル時間 2,849 ms
コンパイル使用メモリ 77,136 KB
実行使用メモリ 58,608 KB
最終ジャッジ日時 2023-10-19 05:17:53
合計ジャッジ時間 9,998 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
58,452 KB
testcase_01 AC 157 ms
58,444 KB
testcase_02 AC 166 ms
58,316 KB
testcase_03 AC 160 ms
58,444 KB
testcase_04 AC 159 ms
58,500 KB
testcase_05 AC 162 ms
58,352 KB
testcase_06 AC 161 ms
58,504 KB
testcase_07 AC 159 ms
58,316 KB
testcase_08 AC 162 ms
58,348 KB
testcase_09 AC 160 ms
58,464 KB
testcase_10 AC 161 ms
58,448 KB
testcase_11 AC 158 ms
58,528 KB
testcase_12 AC 161 ms
58,460 KB
testcase_13 AC 159 ms
58,536 KB
testcase_14 AC 159 ms
58,528 KB
testcase_15 AC 158 ms
58,544 KB
testcase_16 AC 161 ms
58,516 KB
testcase_17 AC 161 ms
58,248 KB
testcase_18 AC 159 ms
58,412 KB
testcase_19 AC 160 ms
58,528 KB
testcase_20 AC 158 ms
58,456 KB
testcase_21 AC 157 ms
58,376 KB
testcase_22 AC 157 ms
58,436 KB
testcase_23 AC 158 ms
58,608 KB
testcase_24 AC 158 ms
58,436 KB
testcase_25 AC 159 ms
58,400 KB
testcase_26 AC 157 ms
58,512 KB
testcase_27 AC 159 ms
58,564 KB
testcase_28 AC 158 ms
58,452 KB
testcase_29 AC 160 ms
58,540 KB
testcase_30 AC 161 ms
58,560 KB
testcase_31 AC 158 ms
58,560 KB
testcase_32 AC 159 ms
58,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Num[] nums = new Num[n];
        for (int i = 0; i < n; i++) {
            nums[i] = new Num(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(nums);
        StringBuilder sb = new StringBuilder();
        for (Num x : nums) {
            sb.append(x).append("\n");
        }
        System.out.print(sb);
    }
    
    static class Num implements Comparable<Num> {
        int child;
        int mother;
        
        public Num(int child, int mother) {
            this.child = child;
            this.mother = mother;
        }
        
        public int compareTo(Num another) {
            return another.child * mother - child * another.mother;
        }
        
        public String toString() {
            return child + " " + mother;
        }
    }
}
0