結果
| 問題 |
No.750 Frac #1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-11-09 21:25:03 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 159 ms / 1,000 ms |
| コード長 | 836 bytes |
| コンパイル時間 | 2,269 ms |
| コンパイル使用メモリ | 83,708 KB |
| 実行使用メモリ | 55,132 KB |
| 最終ジャッジ日時 | 2024-11-21 05:30:40 |
| 合計ジャッジ時間 | 8,271 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
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));
}
}