結果

問題 No.750 Frac #1
ユーザー GrenacheGrenache
提出日時 2019-04-26 16:23:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 1,000 ms
コード長 1,019 bytes
コンパイル時間 4,355 ms
コンパイル使用メモリ 77,284 KB
実行使用メモリ 56,132 KB
最終ジャッジ日時 2023-08-16 04:30:09
合計ジャッジ時間 10,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,720 KB
testcase_01 AC 129 ms
55,724 KB
testcase_02 AC 132 ms
55,816 KB
testcase_03 AC 131 ms
54,100 KB
testcase_04 AC 130 ms
55,560 KB
testcase_05 AC 129 ms
55,788 KB
testcase_06 AC 132 ms
55,648 KB
testcase_07 AC 131 ms
55,732 KB
testcase_08 AC 130 ms
55,976 KB
testcase_09 AC 132 ms
55,912 KB
testcase_10 AC 133 ms
55,492 KB
testcase_11 AC 131 ms
55,916 KB
testcase_12 AC 129 ms
55,892 KB
testcase_13 AC 130 ms
55,768 KB
testcase_14 AC 130 ms
55,548 KB
testcase_15 AC 128 ms
56,056 KB
testcase_16 AC 129 ms
55,644 KB
testcase_17 AC 131 ms
55,976 KB
testcase_18 AC 130 ms
55,708 KB
testcase_19 AC 134 ms
55,444 KB
testcase_20 AC 129 ms
55,480 KB
testcase_21 AC 129 ms
55,628 KB
testcase_22 AC 135 ms
55,668 KB
testcase_23 AC 133 ms
55,784 KB
testcase_24 AC 131 ms
55,640 KB
testcase_25 AC 131 ms
55,736 KB
testcase_26 AC 132 ms
55,788 KB
testcase_27 AC 132 ms
56,076 KB
testcase_28 AC 131 ms
56,132 KB
testcase_29 AC 131 ms
56,124 KB
testcase_30 AC 131 ms
55,708 KB
testcase_31 AC 133 ms
55,916 KB
testcase_32 AC 132 ms
55,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder750 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		List<Integer> nu = new ArrayList<>(n);
		List<Integer> de = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			nu.add(a);
			de.add(b);
			for (int j = nu.size() - 1; j > 0; j--) {
				int pa = nu.get(j - 1);
				int pb = de.get(j - 1);
				if (pa * b < a * pb) {
					Collections.swap(nu, j, j - 1);
					Collections.swap(de, j, j - 1);
				} else {
					break;
				}
			}
		}

		for (int i = 0; i < n; i++) {
			pr.printf("%d %d%n", nu.get(i), de.get(i));
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0