結果
問題 | No.628 Tagの勢い |
ユーザー | takeya_okino |
提出日時 | 2018-01-07 20:19:26 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 289 ms / 2,000 ms |
コード長 | 1,531 bytes |
コンパイル時間 | 3,403 ms |
コンパイル使用メモリ | 85,720 KB |
実行使用メモリ | 48,208 KB |
最終ジャッジ日時 | 2024-04-16 20:03:37 |
合計ジャッジ時間 | 6,922 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 172 ms
42,272 KB |
testcase_01 | AC | 165 ms
42,776 KB |
testcase_02 | AC | 160 ms
42,412 KB |
testcase_03 | AC | 164 ms
42,416 KB |
testcase_04 | AC | 157 ms
42,708 KB |
testcase_05 | AC | 145 ms
41,924 KB |
testcase_06 | AC | 146 ms
42,256 KB |
testcase_07 | AC | 165 ms
42,648 KB |
testcase_08 | AC | 170 ms
42,964 KB |
testcase_09 | AC | 177 ms
42,860 KB |
testcase_10 | AC | 192 ms
43,124 KB |
testcase_11 | AC | 185 ms
42,816 KB |
testcase_12 | AC | 284 ms
47,540 KB |
testcase_13 | AC | 289 ms
48,064 KB |
testcase_14 | AC | 284 ms
47,832 KB |
testcase_15 | AC | 280 ms
48,208 KB |
testcase_16 | AC | 263 ms
47,316 KB |
testcase_17 | AC | 170 ms
42,584 KB |
testcase_18 | AC | 161 ms
42,460 KB |
ソースコード
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; } } } } }