Skip to main content

← Data

Totals per team

medium

The first line has n. Each of the next n lines has a team name and an amount. Print each team with its total, one per line, highest total first; break ties alphabetically.

Example 1: input

5
red 10
blue 5
red 3
green 13
blue 8

Output

blue 13
green 13
red 13

Example 2: input

1
solo 1

Output

solo 1

Plus 1 hidden test when you check your answer.

Your solution

Read from standard input and print the answer. Run it on the examples as often as you like, then check it against every test.

Stuck?

Open hints one at a time. The write-up explains a full solution.

Discussion

Ask a question or share a tip. Please don’t post full solutions. Posts appear once a moderator approves them.

No posts yet.