結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー 37zigen37zigen
提出日時 2016-12-28 06:10:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,549 ms / 4,000 ms
コード長 1,539 bytes
コンパイル時間 6,014 ms
コンパイル使用メモリ 81,316 KB
実行使用メモリ 73,692 KB
最終ジャッジ日時 2023-08-21 17:56:36
合計ジャッジ時間 58,803 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,405 ms
72,424 KB
testcase_01 AC 1,332 ms
72,312 KB
testcase_02 AC 1,271 ms
71,924 KB
testcase_03 AC 1,375 ms
71,976 KB
testcase_04 AC 1,383 ms
71,988 KB
testcase_05 AC 1,308 ms
71,652 KB
testcase_06 AC 1,474 ms
73,692 KB
testcase_07 AC 1,230 ms
73,360 KB
testcase_08 AC 1,233 ms
72,736 KB
testcase_09 AC 1,292 ms
71,868 KB
testcase_10 AC 1,468 ms
71,680 KB
testcase_11 AC 1,459 ms
71,900 KB
testcase_12 AC 1,461 ms
72,188 KB
testcase_13 AC 1,259 ms
72,184 KB
testcase_14 AC 1,428 ms
71,984 KB
testcase_15 AC 1,123 ms
73,396 KB
testcase_16 AC 1,530 ms
69,996 KB
testcase_17 AC 1,549 ms
71,784 KB
testcase_18 AC 1,538 ms
71,868 KB
testcase_19 AC 1,337 ms
72,056 KB
testcase_20 AC 1,343 ms
72,164 KB
testcase_21 AC 1,357 ms
71,704 KB
testcase_22 AC 1,448 ms
71,644 KB
testcase_23 AC 1,394 ms
71,868 KB
testcase_24 AC 1,283 ms
70,168 KB
testcase_25 AC 1,453 ms
71,960 KB
testcase_26 AC 1,336 ms
71,172 KB
testcase_27 AC 1,466 ms
71,656 KB
testcase_28 AC 1,306 ms
72,040 KB
testcase_29 AC 1,473 ms
72,092 KB
testcase_30 AC 123 ms
55,412 KB
testcase_31 AC 124 ms
55,812 KB
testcase_32 AC 1,520 ms
72,680 KB
testcase_33 AC 1,539 ms
72,196 KB
testcase_34 AC 1,255 ms
71,964 KB
testcase_35 AC 125 ms
55,852 KB
testcase_36 AC 126 ms
55,552 KB
testcase_37 AC 152 ms
56,028 KB
testcase_38 AC 148 ms
55,896 KB
testcase_39 AC 224 ms
58,932 KB
testcase_40 AC 226 ms
59,572 KB
testcase_41 AC 415 ms
61,188 KB
testcase_42 AC 410 ms
60,940 KB
testcase_43 AC 392 ms
61,124 KB
testcase_44 AC 396 ms
61,272 KB
testcase_45 AC 243 ms
59,788 KB
testcase_46 AC 489 ms
61,108 KB
testcase_47 AC 494 ms
62,836 KB
権限があれば一括ダウンロードができます

ソースコード

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();
				}
			}
		});
		for(int i=0;i<K;++i){
			System.out.println(ord[i]);
		}
	}

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