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

NWERC25-075.Last Christmas

Hard · 1 s · 256 MB

  • icpc
  • nwerc
  • 2025

A Christmas market is incomplete without live music, and you will find everything from out-of-tune renditions of “Jingle Bells” on a toy xylophone to professional arrangements of Bach's Christmas Oratorio. This year, Jonathan and Merle also want to earn some money playing Christmas songs, but they cannot even agree on which artists, let alone which songs. Jonathan likes Mariah Carey best, while Merle loves the whole Christmas album by the Goo Goo Dolls.

They decide to settle the discussion using statistics and the following strategy. They take nnn past Christmas top-10 lists and count how often each artist appears. Note that an artist may appear multiple times on the same list. The artist with the highest number of appearances is clearly the best! If there is a tie, they look at the artist with the highest number of number 1 hits among the artists with the highest number of appearances. If there is still a tie, they look at highest number of number 2 hits among those, and so on.

Who is the best artist for the Christmas season?

Giriş formatı

The input consists of:

• One line with an integer nnn (1≤n≤1001\leq n \leq 1001≤n≤100), the number of top-10 lists.

• nnn lines, each with 101010 strings sss (1≤∣s∣≤201 \leq |s| \leq 201≤∣s∣≤20), the first names of the artists of the top-10 list from 111 to 101010. Each name only consists of English lowercase letters (a-z). (If Madonna does not need a last name, why would other artists need one?)

Çıxış formatı

Output the name of the best artist according to the rules described above, or “tie” if there is no unique best artist.

Qeyd

\nextsample Madonna and Wham! both appear three times in total, but since Madonna has one more number 1 hit than Wham!, Madonna is the best artist.

Source: Northwestern Europe Regional Contest (NWERC) 2025 · Author: Jeroen Bransen · License: CC BY-SA 4.0 · Original: https://2025.nwerc.eu · Statement adapted for AlgoLens and shared under the same license.

Nümunələr

Giriş #1

3
elton jose bowie eagles elvis wham nat joni bruce minnie
elton madonna wham elvis andy donny madonna aha chuck judy
madonna heart whitney chuck joni wham john yoko nsync stevie

Çıxış #1

madonna

Giriş #2

3
maria a b wham c d e f maria wham
wham g h maria i j k l wham m
n o p q r s t u v maria

Çıxış #2

tie

Giriş #3

2
b a b d e a e a b a
b b b e d a d a a a

Çıxış #3

a