AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

FPC20-009.Ducks and Sharks

Easy · 1 s · 256 MB

  • icpc
  • fpc
  • 2020

The Ducks and the Sharks have had many adventures in the past year. Because the weather has been so nice lately, they want to organise a water polo tournament. After forming the teams, every team plays one match against every other team. Being caught up in the fun of playing the matches, they don't feel like figuring out who won, so they turn to you for help.

You receive a list of matches and the number of goals made by both teams in a match. For each match, the winner gets 3 points, the loser gets 0 points, and in case of a draw both teams get 1 point. It is your job to figure out which teams got the most points, and provide a top five of the best teams.

Giriş formatı

• One line with one integer: 2≤n≤4002 \leq n \leq 4002≤n≤400, the number of teams.

• n⋅(n−1)2\frac{n \cdot (n - 1)}22n⋅(n−1)​ lines (one for each match), containing the names of the two teams and the number of goals both teams made during that match (all separated by one space).

• The name of each team consists of at most 20 characters from the English alphabet (A-Z and a-z).

• The scores are between 000 and 100100100 (inclusive).

Note that every team plays exactly once against every other team.

Çıxış formatı

The names of the top five teams in the water polo competition, followed by their total obtained score. Each team name should be written on a separate line. Each team name and score should be separated by exactly one space. Note:

• If there are less than five teams participating, simply list all participants (see example 1).

• If there are two teams with the same score, order them alphabetically (see example 2).

Qeyd

Source: Freshmen Programming Contest 2020 · License: CC BY-SA 4.0 · Original: https://fpc.wisv.ch · Statement adapted for AlgoLens and shared under the same license. · 1 of the 12 original test cases (the largest) are omitted here to keep the problem lightweight.

Nümunələr

Giriş #1

4
Splashers Sharks 4 2
Ducks Fins 5 2
Fins Splashers 3 5
Ducks Sharks 0 5
Splashers Ducks 8 1
Fins Sharks 1 1

Çıxış #1

Splashers 9
Sharks 4
Ducks 3
Fins 1

Giriş #2

5
A B 5 3
C D 2 9
A E 0 0
C B 1 1
A C 2 5
B E 2 5
D A 1 6
C E 4 2
B D 0 2
E D 5 2

Çıxış #2

A 7
C 7
E 7
D 6
B 1