結果
| 問題 | 
                            No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-12-28 06:10:17 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,683 ms / 4,000 ms | 
| コード長 | 1,539 bytes | 
| コンパイル時間 | 4,230 ms | 
| コンパイル使用メモリ | 85,056 KB | 
| 実行使用メモリ | 78,116 KB | 
| 最終ジャッジ日時 | 2024-12-15 07:31:42 | 
| 合計ジャッジ時間 | 62,241 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 48 | 
ソースコード
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));
	}
}