結果
問題 | No.750 Frac #1 |
ユーザー |
![]() |
提出日時 | 2018-11-09 21:29:07 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 131 ms / 1,000 ms |
コード長 | 857 bytes |
コンパイル時間 | 2,121 ms |
コンパイル使用メモリ | 79,776 KB |
実行使用メモリ | 54,216 KB |
最終ジャッジ日時 | 2024-11-21 05:36:02 |
合計ジャッジ時間 | 7,530 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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(); Data []d = new Data[n]; for(int i = 0; i < n; i++) { int A = sc.nextInt(); int B = sc.nextInt(); d[i] = new Data(A, B, (double)A / B); } sc.close(); Arrays.sort(d, new MyComparator()); for(int i = 0; i < n; i++) { System.out.printf("%d %d\n", d[i].A, d[i].B); } } static class Data{ int A, B; double v; public Data(int A, int B, double v) { this.A = A; this.B = B; this.v = v; } } static class MyComparator implements Comparator<Data>{ @Override public int compare(Data d1, Data d2) { if(d1.v > d2.v) { return -1; }else if(d1.v < d2.v) { return 1; }else { return 0; } } } }