結果

問題 No.628 Tagの勢い
コンテスト
ユーザー lam6er
提出日時 2025-03-20 18:38:05
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 461 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 239 ms
コンパイル使用メモリ 95,972 KB
実行使用メモリ 85,376 KB
最終ジャッジ日時 2026-07-07 07:09:53
合計ジャッジ時間 3,217 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict

n = int(input())
scores = defaultdict(int)

for _ in range(n):
    # Read and ignore No
    input()
    m, s = map(int, input().split())
    tags = input().split()
    for tag in tags:
        scores[tag] += s

# Sort the tags by descending score and ascending lex order
sorted_tags = sorted(scores.items(), key=lambda x: (-x[1], x[0]))

# Output up to 10 tags
for item in sorted_tags[:10]:
    print(f"{item[0]} {item[1]}")
0