結果

問題 No.750 Frac #1
ユーザー 37zigen37zigen
提出日時 2018-11-09 21:25:03
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 121 ms / 1,000 ms
コード長 836 bytes
コンパイル時間 2,939 ms
使用メモリ 38,616 KB
最終ジャッジ日時 2022-12-26 19:28:52
合計ジャッジ時間 8,219 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 115 ms
38,212 KB
testcase_01 AC 111 ms
38,336 KB
testcase_02 AC 112 ms
38,120 KB
testcase_03 AC 110 ms
38,156 KB
testcase_04 AC 114 ms
38,252 KB
testcase_05 AC 115 ms
38,276 KB
testcase_06 AC 116 ms
38,616 KB
testcase_07 AC 117 ms
38,244 KB
testcase_08 AC 121 ms
38,240 KB
testcase_09 AC 114 ms
38,096 KB
testcase_10 AC 115 ms
38,032 KB
testcase_11 AC 117 ms
38,104 KB
testcase_12 AC 110 ms
38,016 KB
testcase_13 AC 111 ms
37,996 KB
testcase_14 AC 108 ms
38,252 KB
testcase_15 AC 115 ms
38,456 KB
testcase_16 AC 110 ms
38,172 KB
testcase_17 AC 114 ms
38,204 KB
testcase_18 AC 115 ms
38,196 KB
testcase_19 AC 115 ms
38,368 KB
testcase_20 AC 112 ms
38,112 KB
testcase_21 AC 112 ms
38,320 KB
testcase_22 AC 114 ms
38,292 KB
testcase_23 AC 113 ms
38,204 KB
testcase_24 AC 116 ms
38,136 KB
testcase_25 AC 115 ms
38,320 KB
testcase_26 AC 116 ms
38,172 KB
testcase_27 AC 116 ms
38,332 KB
testcase_28 AC 109 ms
37,836 KB
testcase_29 AC 113 ms
38,168 KB
testcase_30 AC 116 ms
38,300 KB
testcase_31 AC 119 ms
38,168 KB
testcase_32 AC 118 ms
38,164 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