問題一覧 > 通常問題

No.628 Momentum of Tags

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 305
作問者 : horiesiniti / テスター : はむこ
お気に入りにしたユーザー ProblemId : 1193 / 自分の提出
問題文最終更新日: 2026-06-27 01:31:25
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 179 (順位表) の他の問題:

Problem Statement

You work in the Web industry. This time, you have been asked to do a small task.
Images on a Web service have English word tags (every tag consists only of lowercase letters with no whitespace characters) and scores, and your superiors have instructed you to display the popular tags.

The score of a tag is calculated by summing the scores of the images that have that tag.
Display the top 10 tags in descending order of score, along with their total scores $U_i$. If scores are equal, display the lexicographically smaller tag first.
If there are fewer than 10 kinds of tags, display all tags and scores according to the above rules.

Input

$N$
$No_1$
$M_1\ S_1$
$Tag_{(1,1)}\ Tag_{(1,2)}\ \dots\ Tag_{(1,M_1)}$
$\dots$
$No_N$
$M_N\ S_N$
$Tag_{(N,1)}\ \dots\ Tag_{(N,M_N)}$

$0 \lt N \le 1000$
$0 \le No \lt N$

In one dataset, the first line contains the image $No$.
The second line contains the number of kinds of tags $M$ attached to the image and the score of that image $S,0 \lt M \le 10,0 \lt S \le 10$
The third line contains the tags attached to the image, separated by half-width spaces; each is an English word of at least 1 and at most 20 characters. The same English word does not appear more than once for one image.
This is repeated $N$ times.

Output

Display the top 10 tags in descending order of score, along with their total scores $U_i$. If scores are equal, display the lexicographically smaller tag first.
If there are fewer than 10 kinds of tags, display all tags and scores according to the above rules.

$Tag_1, U_1$
$\dots$
$Tag_i, U_i$
$\dots$
$Tag_{10}, U_{10}$

Print a newline at the end.

Sample

Sample 1
Input
3
0
3 7
run getaway fast
1
2 8
run slow
2
3 5
goodfeeling pretty slow
Output
run 15
slow 13
fast 7
getaway 7
goodfeeling 5
pretty 5

Since there are fewer than 10 kinds of tags, the ranking ends at the 6th one.

Sample 2
Input
7
0
3 9
tiger cowardice tiny
1
4 7
tiger appetite wild ferocity
2
5 3
appetite wild momentum comedian japan
3
4 6
momentum comedian japan naked
4
4 1
eerie unidentified notrecommended china
5
3 4
china showman martialarts
6
4 2
school children lunch tiny
Output
tiger 16
tiny 11
appetite 10
wild 10
comedian 9
cowardice 9
japan 9
momentum 9
ferocity 7
naked 6

Since there are 10 or more kinds of tags, display up to the 10th one. Note that tags with equal scores are displayed in lexicographic order. You may assume that tags consist of lowercase letters with no spaces.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。