結果

問題 No.628 Tagの勢い
ユーザー GrenacheGrenache
提出日時 2018-01-06 12:46:01
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,432 bytes
コンパイル時間 4,175 ms
コンパイル使用メモリ 80,192 KB
実行使用メモリ 46,940 KB
最終ジャッジ日時 2024-04-16 20:02:44
合計ジャッジ時間 7,445 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 138 ms
41,564 KB
testcase_02 RE -
testcase_03 AC 137 ms
41,452 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 127 ms
41,652 KB
testcase_07 AC 141 ms
41,716 KB
testcase_08 AC 147 ms
41,444 KB
testcase_09 AC 141 ms
41,528 KB
testcase_10 AC 167 ms
41,992 KB
testcase_11 AC 144 ms
42,028 KB
testcase_12 AC 234 ms
46,196 KB
testcase_13 AC 238 ms
46,388 KB
testcase_14 AC 237 ms
46,940 KB
testcase_15 AC 233 ms
46,660 KB
testcase_16 AC 209 ms
46,328 KB
testcase_17 RE -
testcase_18 AC 132 ms
41,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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; i < 10; 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);
		}
	}
}
0