結果

問題 No.750 Frac #1
ユーザー 37zigen37zigen
提出日時 2018-11-09 21:25:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 155 ms / 1,000 ms
コード長 836 bytes
コンパイル時間 3,079 ms
コンパイル使用メモリ 76,504 KB
実行使用メモリ 57,084 KB
最終ジャッジ日時 2023-08-13 11:07:46
合計ジャッジ時間 9,473 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
57,012 KB
testcase_01 AC 152 ms
56,748 KB
testcase_02 AC 154 ms
56,884 KB
testcase_03 AC 152 ms
56,636 KB
testcase_04 AC 151 ms
56,880 KB
testcase_05 AC 153 ms
56,556 KB
testcase_06 AC 153 ms
56,864 KB
testcase_07 AC 152 ms
56,948 KB
testcase_08 AC 150 ms
56,436 KB
testcase_09 AC 152 ms
56,828 KB
testcase_10 AC 150 ms
56,716 KB
testcase_11 AC 152 ms
56,692 KB
testcase_12 AC 152 ms
56,836 KB
testcase_13 AC 151 ms
56,932 KB
testcase_14 AC 150 ms
56,564 KB
testcase_15 AC 153 ms
56,808 KB
testcase_16 AC 152 ms
56,716 KB
testcase_17 AC 155 ms
56,472 KB
testcase_18 AC 151 ms
57,084 KB
testcase_19 AC 151 ms
56,400 KB
testcase_20 AC 150 ms
56,980 KB
testcase_21 AC 154 ms
56,980 KB
testcase_22 AC 151 ms
56,872 KB
testcase_23 AC 153 ms
56,760 KB
testcase_24 AC 151 ms
56,952 KB
testcase_25 AC 151 ms
56,804 KB
testcase_26 AC 153 ms
56,928 KB
testcase_27 AC 150 ms
56,612 KB
testcase_28 AC 152 ms
56,808 KB
testcase_29 AC 150 ms
56,616 KB
testcase_30 AC 150 ms
56,436 KB
testcase_31 AC 151 ms
56,636 KB
testcase_32 AC 150 ms
56,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[][] x = new long[n][2];
		for (int i = 0; i < n; ++i) {
			x[i][0] = sc.nextLong();
			x[i][1] = sc.nextLong();
		}
		Arrays.sort(x, new Comparator<long[]>() {
			@Override
			public int compare(long[] o1, long[] o2) {
				return Double.compare((double) o1[0] / o1[1], (double) o2[0] / o2[1]);
			}
		});
		for (int i = n - 1; i >= 0; --i) {
			System.out.println(x[i][0] + " " + x[i][1]);
		}
	}

	static long gcd(long a, long b) {
		if (a > b)
			return gcd(b, a);
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0