結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
takeya_okino
|
| 提出日時 | 2018-01-07 20:19:26 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 272 ms / 2,000 ms |
| コード長 | 1,531 bytes |
| コンパイル時間 | 2,759 ms |
| コンパイル使用メモリ | 84,684 KB |
| 実行使用メモリ | 48,352 KB |
| 最終ジャッジ日時 | 2024-10-07 22:21:47 |
| 合計ジャッジ時間 | 6,535 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
HashMap<String, Integer> map = new HashMap<String, Integer>();
for(int i = 0; i < n; i++) {
int ni = sc.nextInt();
int m = sc.nextInt();
int s = sc.nextInt();
s *= (-1);
for(int j = 0; j < m; j++) {
String tag = sc.next();
if(map.containsKey(tag)) {
map.put(tag, map.get(tag) + s);
} else {
map.put(tag, s);
}
}
}
HashMap<Integer, ArrayList<String>> map2 = new HashMap<Integer, ArrayList<String>>();
for(String t : map.keySet()) {
int score = map.get(t);
if(map2.containsKey(score)) {
ArrayList<String> list = map2.get(score);
list.add(t);
map2.put(score, list);
} else {
ArrayList<String> list = new ArrayList<String>();
list.add(t);
map2.put(score, list);
}
}
ArrayList<Integer> key = new ArrayList<>(map2.keySet());
Collections.sort(key);
int flg = 0;
for(int i = 0; i < key.size(); i++) {
if(flg >= 10) break;
int tensuu = key.get(i);
ArrayList<String> list = map2.get(tensuu);
tensuu *= (-1);
Collections.sort(list);
for(int j = 0; j < list.size(); j++) {
String a = list.get(j);
if(flg < 10) {
System.out.println(a + " " + tensuu);
flg++;
} else {
break;
}
}
}
}
}
takeya_okino