結果

問題 No.628 Tagの勢い
ユーザー lam6er
提出日時 2025-03-20 18:38:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 74,524 KB
最終ジャッジ日時 2025-03-20 18:38:09
合計ジャッジ時間 2,048 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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