結果
| 問題 |
No.750 Frac #1
|
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2019-02-19 20:54:44 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 156 ms / 1,000 ms |
| コード長 | 1,163 bytes |
| コンパイル時間 | 2,222 ms |
| コンパイル使用メモリ | 80,136 KB |
| 実行使用メモリ | 55,100 KB |
| 最終ジャッジ日時 | 2024-10-12 19:26:52 |
| 合計ジャッジ時間 | 8,425 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
List<Decimal> list = new ArrayList<>();
for(int i=0; i<n; i++) {
int a = sc.nextInt();
int b = sc.nextInt();
list.add(new Decimal(a,b));
}
Collections.sort(list, new DecimalComparator());
for(int i=0; i<n; i++) {
System.out.println( list.get(i).getNumerator() + " " + list.get(i).getDenominator() );
}
}
}
class Decimal {
private int numerator;
private int denominator;
public Decimal(int numerator, int denominator) {
this.numerator = numerator;
this.denominator = denominator;
}
public int getNumerator() {
return numerator;
}
public int getDenominator() {
return denominator;
}
}
class DecimalComparator implements Comparator<Decimal> {
public int compare(Decimal d1, Decimal d2) {
return d1.getDenominator() * d2.getNumerator() - d2.getDenominator() * d1.getNumerator();
}
}
kohaku_kohaku