結果
問題 | No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい |
ユーザー | uafr_cs |
提出日時 | 2016-10-14 23:27:12 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,612 ms / 4,000 ms |
コード長 | 2,189 bytes |
コンパイル時間 | 4,464 ms |
コンパイル使用メモリ | 90,568 KB |
実行使用メモリ | 78,764 KB |
最終ジャッジ日時 | 2024-11-22 06:20:59 |
合計ジャッジ時間 | 54,326 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,612 ms
78,764 KB |
testcase_01 | AC | 1,470 ms
77,424 KB |
testcase_02 | AC | 1,275 ms
67,776 KB |
testcase_03 | AC | 1,430 ms
65,224 KB |
testcase_04 | AC | 1,372 ms
65,216 KB |
testcase_05 | AC | 1,387 ms
69,796 KB |
testcase_06 | AC | 1,551 ms
78,264 KB |
testcase_07 | AC | 1,350 ms
75,792 KB |
testcase_08 | AC | 1,233 ms
70,240 KB |
testcase_09 | AC | 1,269 ms
62,944 KB |
testcase_10 | AC | 1,234 ms
62,304 KB |
testcase_11 | AC | 1,281 ms
62,552 KB |
testcase_12 | AC | 1,256 ms
62,368 KB |
testcase_13 | AC | 1,101 ms
61,848 KB |
testcase_14 | AC | 1,146 ms
61,844 KB |
testcase_15 | AC | 944 ms
61,572 KB |
testcase_16 | AC | 1,350 ms
63,432 KB |
testcase_17 | AC | 1,366 ms
62,628 KB |
testcase_18 | AC | 1,360 ms
62,904 KB |
testcase_19 | AC | 1,095 ms
61,476 KB |
testcase_20 | AC | 1,154 ms
61,876 KB |
testcase_21 | AC | 1,116 ms
61,312 KB |
testcase_22 | AC | 1,175 ms
62,520 KB |
testcase_23 | AC | 1,161 ms
61,880 KB |
testcase_24 | AC | 996 ms
61,192 KB |
testcase_25 | AC | 1,232 ms
62,464 KB |
testcase_26 | AC | 1,134 ms
61,464 KB |
testcase_27 | AC | 1,229 ms
61,672 KB |
testcase_28 | AC | 1,087 ms
61,368 KB |
testcase_29 | AC | 1,252 ms
62,428 KB |
testcase_30 | AC | 130 ms
41,276 KB |
testcase_31 | AC | 123 ms
40,884 KB |
testcase_32 | AC | 1,335 ms
63,300 KB |
testcase_33 | AC | 1,393 ms
63,384 KB |
testcase_34 | AC | 1,187 ms
64,848 KB |
testcase_35 | AC | 134 ms
41,280 KB |
testcase_36 | AC | 134 ms
41,104 KB |
testcase_37 | AC | 161 ms
41,772 KB |
testcase_38 | AC | 166 ms
41,512 KB |
testcase_39 | AC | 235 ms
44,240 KB |
testcase_40 | AC | 234 ms
44,900 KB |
testcase_41 | AC | 429 ms
48,328 KB |
testcase_42 | AC | 429 ms
48,248 KB |
testcase_43 | AC | 441 ms
48,488 KB |
testcase_44 | AC | 420 ms
48,384 KB |
testcase_45 | AC | 262 ms
44,988 KB |
testcase_46 | AC | 527 ms
48,612 KB |
testcase_47 | AC | 527 ms
48,484 KB |
ソースコード
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); } } }