結果
| 問題 |
No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
|
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2016-10-14 23:24:44 |
| 言語 | Java (openjdk 23) |
| 結果 |
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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 46 |
ソースコード
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);
}
}
}
uafr_cs