結果
| 問題 | No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい |
| コンテスト | |
| ユーザー |
37zigen
|
| 提出日時 | 2016-12-28 06:11:49 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,611 bytes |
| 記録 | |
| コンパイル時間 | 4,709 ms |
| コンパイル使用メモリ | 92,236 KB |
| 実行使用メモリ | 82,224 KB |
| 最終ジャッジ日時 | 2024-12-15 07:28:47 |
| 合計ジャッジ時間 | 57,484 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 48 |
ソースコード
package yukicoder;
import java.util.*;
public class Q433 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
int[] S = new int[N];
int[] P = new int[N];
String[] U = new String[N];
for (int i = 0; i < N; ++i) {
S[i] = sc.nextInt();
P[i] = sc.nextInt();
U[i] = sc.next();
}
Integer[] ord = new Integer[N];
for (int i = 0; i < N; ++i) {
ord[i] = i;
}
Arrays.sort(ord, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
if (S[o1] != S[o2]) {
return -Integer.compare(S[o1], S[o2]);
} else {
return Integer.compare(P[o1], P[o2]);
}
}
});
int[] C = new int[N];
HashMap<String, Integer> map = new HashMap<>();
for (int i = 0; i < N; ++i) {
if (!map.containsKey(U[ord[i]])) {
map.put(U[ord[i]], 0);
} else {
C[ord[i]] = map.get(U[ord[i]]) + 1;
map.put(U[ord[i]], map.get(U[ord[i]]) + 1);
}
}
Arrays.sort(ord, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
if (S[o1] != S[o2]) {
return -Integer.compare(S[o1], S[o2]);
} else if (C[o1] != C[o2]) {
return Integer.compare(C[o1], C[o2]);
} else if (P[o1] != P[o2]) {
return Integer.compare(P[o1], P[o2]);
} else {
throw new AssertionError();
}
}
});
StringBuilder sb = new StringBuilder();
for (int i = 0; i < K; ++i) {
sb.append(ord[i]+"\n");
}
System.out.println(sb);
}
static void tr(Object... objects) {
System.out.println(Arrays.deepToString(objects));
}
}
37zigen