Problem 1900 --Problem C - Election

1900: Problem C - Election

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $7$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签

Problem C - Election

Canada has a multi-party system of government. Each candidate is generally associated with a party, and the party whose candidates win the most ridings generally forms the government. Some candidates run as independents, meaning they are not associated with any party. Your job is to count the votes for a particular riding and to determine the party with which the winning candidate is associated.

The first line of input contains a positive integer n satisfying 2 <= n <= 20, the number of candidates in the riding. npairs of lines follow: the first line in each pair is the name of the candidate, up to 80 characters; the second line is the name of the party, up to 80 characters, or the word "independent" if the candidate has no party. No candidate name is repeated and no party name is repeated in the input. No lines contain leading or trailing blanks.

Output consists of a single line containing one of:

  • The name of the party with whom the winning candidate is associated, if there is a winning candidate and that candidate is associated with a party.
  • The word "independent" if there is a winning candidate and that candidate is not associated with a party.
  • The word "tie" if there is no winner; that is, if no candidate receives more votes than every other candidate.

3
Marilyn Manson
Rhinoceros
Jane Doe
Family Coalition
John Smith
independent
6
John Smith
Marilyn Manson
Marilyn Manson
Jane Doe
John Smith
Marilyn Manson
Rhinoceros

推荐代码 查看1900 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] AOJ大管家 84415 2017-04-27 15:28:47
内存最少[$952 $KB] AOJ大管家 84415 2017-04-27 15:28:47
第一AC AOJ大管家 84415 2017-04-27 15:28:47
第一挑战 AOJ大管家 84415 2017-04-27 15:28:47

赛题来源/所属竞赛 NA N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛