結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー uafr_csuafr_cs
提出日時 2016-10-14 23:27:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,255 ms / 4,000 ms
コード長 2,189 bytes
コンパイル時間 2,446 ms
コンパイル使用メモリ 76,044 KB
実行使用メモリ 90,504 KB
最終ジャッジ日時 2023-08-14 10:22:10
合計ジャッジ時間 42,257 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,194 ms
84,376 KB
testcase_01 AC 1,120 ms
84,360 KB
testcase_02 AC 886 ms
73,332 KB
testcase_03 AC 1,025 ms
70,228 KB
testcase_04 AC 993 ms
69,900 KB
testcase_05 AC 998 ms
75,180 KB
testcase_06 AC 1,255 ms
90,504 KB
testcase_07 AC 956 ms
83,812 KB
testcase_08 AC 884 ms
76,364 KB
testcase_09 AC 898 ms
69,020 KB
testcase_10 AC 930 ms
68,872 KB
testcase_11 AC 990 ms
70,016 KB
testcase_12 AC 940 ms
70,228 KB
testcase_13 AC 826 ms
69,128 KB
testcase_14 AC 843 ms
68,996 KB
testcase_15 AC 718 ms
68,452 KB
testcase_16 AC 981 ms
69,980 KB
testcase_17 AC 966 ms
70,020 KB
testcase_18 AC 1,032 ms
69,736 KB
testcase_19 AC 773 ms
68,676 KB
testcase_20 AC 845 ms
68,148 KB
testcase_21 AC 802 ms
66,780 KB
testcase_22 AC 982 ms
69,088 KB
testcase_23 AC 838 ms
67,928 KB
testcase_24 AC 759 ms
66,908 KB
testcase_25 AC 917 ms
69,100 KB
testcase_26 AC 828 ms
66,828 KB
testcase_27 AC 926 ms
69,188 KB
testcase_28 AC 854 ms
67,132 KB
testcase_29 AC 995 ms
70,416 KB
testcase_30 AC 105 ms
55,760 KB
testcase_31 AC 105 ms
55,756 KB
testcase_32 AC 953 ms
70,944 KB
testcase_33 AC 1,026 ms
69,332 KB
testcase_34 AC 934 ms
70,572 KB
testcase_35 AC 109 ms
55,932 KB
testcase_36 AC 112 ms
55,692 KB
testcase_37 AC 141 ms
55,944 KB
testcase_38 AC 138 ms
56,588 KB
testcase_39 AC 205 ms
58,624 KB
testcase_40 AC 204 ms
61,144 KB
testcase_41 AC 334 ms
60,704 KB
testcase_42 AC 319 ms
60,544 KB
testcase_43 AC 330 ms
60,820 KB
testcase_44 AC 329 ms
60,616 KB
testcase_45 AC 213 ms
59,324 KB
testcase_46 AC 394 ms
60,256 KB
testcase_47 AC 401 ms
60,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	
	public static class Team implements Comparable<Team>{
		int index, score, penalty, univ, univ_count;
		
		public Team(int index, int score, int penalty, int univ, int univ_count){
			this.index = index;
			this.score = score;
			this.penalty = penalty;
			this.univ = univ;
			this.univ_count = univ_count;
		}
		
		public int compareTo(Team arg0){
			if(this.score != arg0.score){
				return -Integer.compare(this.score, arg0.score);
			}else if(this.univ_count != arg0.univ_count){
				return Integer.compare(this.univ_count, arg0.univ_count);
			}else{
				return Integer.compare(this.penalty, arg0.penalty);
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int K = sc.nextInt();
		
		Team[] teams = new Team[N];
		for(int i = 0; i < N; i++){
			final int S = sc.nextInt();
			final int P = sc.nextInt();
			final int U = sc.nextInt();
			
			teams[i] = new Team(i, S, P, U, 0);
		}
		
		HashMap<Integer, PriorityQueue<Team>> univ_hash = new HashMap<Integer, PriorityQueue<Team>>();
		HashMap<Integer, Integer> univ_count = new HashMap<Integer, Integer>();
		for(final Team t : teams){
			if(!univ_hash.containsKey(t.univ)){
				univ_hash.put(t.univ, new PriorityQueue<Team>());
			}
			
			if(!univ_count.containsKey(t.univ)){
				univ_count.put(t.univ, 0);
			}
			
			univ_hash.get(t.univ).add(t);
		}
		
		
		LinkedList<Team> answer = new LinkedList<Team>();
		PriorityQueue<Team> queue = new PriorityQueue<Team>();
		for(final PriorityQueue<Team> q : univ_hash.values()){
			queue.add(q.poll());
		}
		
		
		for(int i = 0; i < K; i++){
			final Team ok = queue.poll();
			answer.add(ok);
			
			final Team next_add = univ_hash.get(ok.univ).poll();
			if(next_add != null){
				next_add.univ_count = ok.univ_count + 1;
				queue.add(next_add);
			}
		}
		
		for(final Team t : answer){
			System.out.println(t.index);
		}
		
	}

}
0