結果
問題 | No.628 Tagの勢い |
ユーザー | Grenache |
提出日時 | 2018-01-06 12:47:16 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 235 ms / 2,000 ms |
コード長 | 1,463 bytes |
コンパイル時間 | 4,080 ms |
コンパイル使用メモリ | 83,040 KB |
実行使用メモリ | 47,244 KB |
最終ジャッジ日時 | 2024-04-16 20:02:58 |
合計ジャッジ時間 | 7,208 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 117 ms
41,776 KB |
testcase_01 | AC | 129 ms
41,552 KB |
testcase_02 | AC | 113 ms
41,540 KB |
testcase_03 | AC | 132 ms
41,552 KB |
testcase_04 | AC | 127 ms
41,716 KB |
testcase_05 | AC | 132 ms
41,392 KB |
testcase_06 | AC | 129 ms
41,924 KB |
testcase_07 | AC | 130 ms
41,712 KB |
testcase_08 | AC | 136 ms
41,800 KB |
testcase_09 | AC | 131 ms
41,992 KB |
testcase_10 | AC | 150 ms
41,932 KB |
testcase_11 | AC | 152 ms
41,752 KB |
testcase_12 | AC | 234 ms
47,012 KB |
testcase_13 | AC | 235 ms
47,040 KB |
testcase_14 | AC | 214 ms
46,324 KB |
testcase_15 | AC | 234 ms
47,244 KB |
testcase_16 | AC | 213 ms
46,160 KB |
testcase_17 | AC | 128 ms
41,472 KB |
testcase_18 | AC | 121 ms
41,576 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.Map.*; public class Main_yukicoder628 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); Map<String, Integer> hm = new HashMap<>(); for (int i = 0; i < n; i++) { @SuppressWarnings("unused") int no = sc.nextInt(); int m = sc.nextInt(); int s = sc.nextInt(); for (int j = 0; j < m; j++) { String tag = sc.next(); if (hm.containsKey(tag)) { hm.put(tag, hm.get(tag) + s); } else { hm.put(tag, s); } } } List<Pair> ans = new ArrayList<>(); for (Entry<String, Integer> e : hm.entrySet()) { ans.add(new Pair(e.getKey(), e.getValue())); } Collections.sort(ans); for (int i = 0, size = ans.size(); i < 10 && i < size; i++) { Pair e = ans.get(i); pr.printf("%s %d\n", e.a, e.b); } } private static class Pair implements Comparable<Pair> { String a; int b; Pair(String a, int b) { this.a = a; this.b = b; } @Override public int compareTo(Pair o) { if (b == o.b) { return a.compareTo(o.a); } return Integer.compare(o.b, b); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }