結果
問題 | No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい |
ユーザー | hermione17 |
提出日時 | 2016-10-14 23:50:03 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 2,073 ms / 4,000 ms |
コード長 | 2,137 bytes |
コンパイル時間 | 4,098 ms |
コンパイル使用メモリ | 80,496 KB |
実行使用メモリ | 79,908 KB |
最終ジャッジ日時 | 2024-11-22 07:15:09 |
合計ジャッジ時間 | 61,083 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,893 ms
77,544 KB |
testcase_01 | AC | 1,789 ms
73,356 KB |
testcase_02 | AC | 1,347 ms
70,472 KB |
testcase_03 | AC | 1,541 ms
67,936 KB |
testcase_04 | AC | 1,475 ms
67,664 KB |
testcase_05 | AC | 1,570 ms
71,516 KB |
testcase_06 | AC | 2,073 ms
79,908 KB |
testcase_07 | AC | 1,486 ms
72,960 KB |
testcase_08 | AC | 1,466 ms
71,812 KB |
testcase_09 | AC | 1,445 ms
70,584 KB |
testcase_10 | AC | 1,335 ms
69,756 KB |
testcase_11 | AC | 1,451 ms
72,148 KB |
testcase_12 | AC | 1,404 ms
70,196 KB |
testcase_13 | AC | 1,208 ms
69,944 KB |
testcase_14 | AC | 1,312 ms
70,040 KB |
testcase_15 | AC | 1,145 ms
66,628 KB |
testcase_16 | AC | 1,478 ms
72,808 KB |
testcase_17 | AC | 1,467 ms
68,116 KB |
testcase_18 | AC | 1,480 ms
75,952 KB |
testcase_19 | AC | 1,179 ms
69,592 KB |
testcase_20 | AC | 1,244 ms
68,512 KB |
testcase_21 | AC | 1,275 ms
70,196 KB |
testcase_22 | AC | 1,403 ms
73,740 KB |
testcase_23 | AC | 1,328 ms
69,856 KB |
testcase_24 | AC | 1,168 ms
68,992 KB |
testcase_25 | AC | 1,402 ms
70,192 KB |
testcase_26 | AC | 1,279 ms
69,392 KB |
testcase_27 | AC | 1,378 ms
69,692 KB |
testcase_28 | AC | 1,222 ms
69,352 KB |
testcase_29 | AC | 1,362 ms
67,520 KB |
testcase_30 | AC | 159 ms
48,188 KB |
testcase_31 | AC | 157 ms
48,032 KB |
testcase_32 | AC | 1,518 ms
76,968 KB |
testcase_33 | AC | 1,566 ms
75,148 KB |
testcase_34 | AC | 1,237 ms
66,888 KB |
testcase_35 | AC | 163 ms
48,292 KB |
testcase_36 | AC | 165 ms
48,152 KB |
testcase_37 | AC | 188 ms
48,356 KB |
testcase_38 | AC | 193 ms
48,276 KB |
testcase_39 | AC | 258 ms
51,452 KB |
testcase_40 | AC | 272 ms
51,904 KB |
testcase_41 | AC | 458 ms
54,008 KB |
testcase_42 | AC | 453 ms
54,152 KB |
testcase_43 | AC | 487 ms
53,748 KB |
testcase_44 | AC | 458 ms
54,772 KB |
testcase_45 | AC | 291 ms
51,784 KB |
testcase_46 | AC | 566 ms
54,248 KB |
testcase_47 | AC | 649 ms
54,048 KB |
ソースコード
import java.io.PrintStream; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; public class Y433 { Y433() throws Exception { Scanner in = new Scanner(System.in); PrintStream out = new PrintStream(System.out); int n = in.nextInt(); int k = in.nextInt(); School[] school = new School[100001]; for (int i = 0; i < 100001; i++) { school[i] = new School(); } for (int i = 0; i < n; i++) { int s = in.nextInt(); int p = in.nextInt(); int u = in.nextInt(); school[u].add(new Team(s, p, i)); } PriorityQueue<School> pq = new PriorityQueue<>(); for (int i = 0; i < 100001; i++) { if (school[i].teams.size() > 0) { school[i].sort(); pq.add(school[i]); } } for (int i = 0; i < k; i++) { School sch = pq.poll(); Team team = sch.getLast(); out.println(sch.getLast().name); sch.pop(); if (sch.teams.size() > 0) { pq.add(sch); } } } class Team implements Comparable { int s, p, name; Team(int s, int p, int name) { this.s = s; this.p = p; this.name = name; } @Override public int compareTo(Object o) { Team that = (Team) o; if (s != that.s) return Integer.compare(s, that.s); return Integer.compare(that.p, p); } } class School implements Comparable { int passed; List<Team> teams; School() { passed = 0; teams = new ArrayList(); } void add(Team t) { teams.add(t); } Team pop() { Team team = getLast(); teams.remove(teams.size() - 1); passed++; return team; } void sort() { teams.sort(null); } Team getLast() { return teams.get(teams.size() - 1); } @Override public int compareTo(Object o) { School that = (School) o; if (getLast().s != that.getLast().s) return Integer.compare(that.getLast().s, getLast().s); if (passed != that.passed) return Integer.compare(passed, that.passed); return Integer.compare(getLast().p, that.getLast().p); } } public static void main(String argv[]) throws Exception { new Y433(); } }