結果

問題 No.571 3人兄弟(その2)
ユーザー GrenacheGrenache
提出日時 2017-10-07 11:09:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 1,367 bytes
コンパイル時間 3,225 ms
コンパイル使用メモリ 80,184 KB
実行使用メモリ 41,656 KB
最終ジャッジ日時 2024-04-28 12:44:55
合計ジャッジ時間 5,421 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
40,216 KB
testcase_01 AC 111 ms
41,656 KB
testcase_02 AC 108 ms
41,052 KB
testcase_03 AC 118 ms
40,380 KB
testcase_04 AC 101 ms
40,576 KB
testcase_05 AC 105 ms
41,064 KB
testcase_06 AC 114 ms
41,384 KB
testcase_07 AC 112 ms
41,408 KB
testcase_08 AC 104 ms
40,476 KB
testcase_09 AC 111 ms
41,256 KB
testcase_10 AC 113 ms
41,540 KB
testcase_11 AC 101 ms
40,412 KB
testcase_12 AC 100 ms
40,040 KB
testcase_13 AC 109 ms
41,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder571 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		List<Pair> hw = new ArrayList<>();
		for (int i = 0; i < 3; i++) {
			int h = sc.nextInt();
			int w = sc.nextInt();

			hw.add(new Pair(h, w, (char)('A' + i)));
		}
		Collections.sort(hw);

		for (Pair e : hw) {
			pr.println(e.c);
		}
	}

	private static class Pair implements Comparable<Pair> {
		int a;
		int b;
		char c;

		Pair(int a, int b, char c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

		@Override
		public int compareTo(Pair o) {
			if (a == o.a) {
				return Integer.compare(b, o.b);
			}

			return Integer.compare(o.a, a);
		}

		@Override
		public int hashCode() {
			return Integer.hashCode(a);
		}

		@Override
		public String toString() {
			// [xxx, xxxx]
			StringBuilder stmp = new StringBuilder(32);
			stmp.append('[');
			stmp.append(a);
			stmp.append(',');
			stmp.append(' ');
			stmp.append(b);
			stmp.append(']');

			return stmp.toString();
		}
	}

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

		solve();

		pr.close();
		sc.close();
	}

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