結果

問題 No.750 Frac #1
ユーザー 37zigen37zigen
提出日時 2018-11-09 21:25:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 173 ms / 1,000 ms
コード長 836 bytes
コンパイル時間 3,551 ms
コンパイル使用メモリ 80,804 KB
実行使用メモリ 56,812 KB
最終ジャッジ日時 2024-05-01 04:26:30
合計ジャッジ時間 8,508 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
55,072 KB
testcase_01 AC 139 ms
54,328 KB
testcase_02 AC 173 ms
54,872 KB
testcase_03 AC 157 ms
55,080 KB
testcase_04 AC 157 ms
54,880 KB
testcase_05 AC 155 ms
55,064 KB
testcase_06 AC 158 ms
55,148 KB
testcase_07 AC 155 ms
55,048 KB
testcase_08 AC 152 ms
54,932 KB
testcase_09 AC 152 ms
54,856 KB
testcase_10 AC 142 ms
54,212 KB
testcase_11 AC 156 ms
54,940 KB
testcase_12 AC 155 ms
55,028 KB
testcase_13 AC 156 ms
54,828 KB
testcase_14 AC 156 ms
56,812 KB
testcase_15 AC 153 ms
54,912 KB
testcase_16 AC 157 ms
54,728 KB
testcase_17 AC 152 ms
54,828 KB
testcase_18 AC 157 ms
54,884 KB
testcase_19 AC 154 ms
54,996 KB
testcase_20 AC 151 ms
54,928 KB
testcase_21 AC 151 ms
54,908 KB
testcase_22 AC 150 ms
55,100 KB
testcase_23 AC 154 ms
54,936 KB
testcase_24 AC 152 ms
55,088 KB
testcase_25 AC 152 ms
55,112 KB
testcase_26 AC 140 ms
54,500 KB
testcase_27 AC 140 ms
55,004 KB
testcase_28 AC 151 ms
54,832 KB
testcase_29 AC 156 ms
55,000 KB
testcase_30 AC 153 ms
54,896 KB
testcase_31 AC 154 ms
54,892 KB
testcase_32 AC 155 ms
54,852 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