結果
問題 | No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい |
ユーザー | uafr_cs |
提出日時 | 2016-10-14 23:24:44 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,972 bytes |
コンパイル時間 | 2,923 ms |
コンパイル使用メモリ | 82,616 KB |
実行使用メモリ | 91,216 KB |
最終ジャッジ日時 | 2024-11-22 10:33:42 |
合計ジャッジ時間 | 51,143 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | AC | 133 ms
41,108 KB |
testcase_31 | AC | 132 ms
41,396 KB |
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 | - |
ソースコード
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){ return Integer.compare(arg0.score, this.score); } } 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); } } }