結果

問題 No.628 Tagの勢い
ユーザー lam6er
提出日時 2025-03-20 20:16:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,216 KB
実行使用メモリ 74,840 KB
最終ジャッジ日時 2025-03-20 20:16:41
合計ジャッジ時間 1,740 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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