結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー 37zigen37zigen
提出日時 2016-12-28 06:11:49
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,611 bytes
コンパイル時間 6,518 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 77,208 KB
最終ジャッジ日時 2023-08-21 17:54:24
合計ジャッジ時間 58,758 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.*;

public class Q433 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] S = new int[N];
		int[] P = new int[N];
		String[] U = new String[N];
		for (int i = 0; i < N; ++i) {
			S[i] = sc.nextInt();
			P[i] = sc.nextInt();
			U[i] = sc.next();
		}
		Integer[] ord = new Integer[N];
		for (int i = 0; i < N; ++i) {
			ord[i] = i;
		}
		Arrays.sort(ord, new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				if (S[o1] != S[o2]) {
					return -Integer.compare(S[o1], S[o2]);
				} else {
					return Integer.compare(P[o1], P[o2]);
				}
			}
		});
		int[] C = new int[N];
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			if (!map.containsKey(U[ord[i]])) {
				map.put(U[ord[i]], 0);
			} else {
				C[ord[i]] = map.get(U[ord[i]]) + 1;
				map.put(U[ord[i]], map.get(U[ord[i]]) + 1);
			}
		}
		Arrays.sort(ord, new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				if (S[o1] != S[o2]) {
					return -Integer.compare(S[o1], S[o2]);
				} else if (C[o1] != C[o2]) {
					return Integer.compare(C[o1], C[o2]);
				} else if (P[o1] != P[o2]) {
					return Integer.compare(P[o1], P[o2]);
				} else {
					throw new AssertionError();
				}
			}
		});
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < K; ++i) {
			sb.append(ord[i]+"\n");
		}
		System.out.println(sb);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0