結果

問題 No.750 Frac #1
ユーザー GrenacheGrenache
提出日時 2019-04-26 16:23:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 1,000 ms
コード長 1,019 bytes
コンパイル時間 3,938 ms
コンパイル使用メモリ 79,244 KB
実行使用メモリ 41,836 KB
最終ジャッジ日時 2024-05-03 13:52:24
合計ジャッジ時間 9,630 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
41,544 KB
testcase_01 AC 139 ms
41,772 KB
testcase_02 AC 135 ms
41,548 KB
testcase_03 AC 136 ms
41,124 KB
testcase_04 AC 125 ms
39,988 KB
testcase_05 AC 136 ms
41,156 KB
testcase_06 AC 125 ms
40,648 KB
testcase_07 AC 118 ms
40,280 KB
testcase_08 AC 132 ms
41,276 KB
testcase_09 AC 132 ms
41,472 KB
testcase_10 AC 123 ms
40,152 KB
testcase_11 AC 138 ms
41,316 KB
testcase_12 AC 133 ms
41,232 KB
testcase_13 AC 136 ms
41,572 KB
testcase_14 AC 126 ms
40,204 KB
testcase_15 AC 133 ms
41,432 KB
testcase_16 AC 141 ms
41,216 KB
testcase_17 AC 139 ms
41,564 KB
testcase_18 AC 138 ms
41,572 KB
testcase_19 AC 139 ms
41,472 KB
testcase_20 AC 137 ms
41,564 KB
testcase_21 AC 133 ms
41,560 KB
testcase_22 AC 135 ms
41,068 KB
testcase_23 AC 138 ms
41,804 KB
testcase_24 AC 137 ms
41,836 KB
testcase_25 AC 135 ms
41,360 KB
testcase_26 AC 134 ms
41,168 KB
testcase_27 AC 132 ms
41,232 KB
testcase_28 AC 137 ms
41,796 KB
testcase_29 AC 123 ms
39,956 KB
testcase_30 AC 138 ms
41,344 KB
testcase_31 AC 140 ms
41,204 KB
testcase_32 AC 140 ms
41,664 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