B. F1 Champions
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Formula One championship consists of series of races called Grand Prix. After every race drivers receive points according to their final position. Only the top 10 drivers receive points in the following order 25, 18, 15, 12, 10, 8, 6, 4, 2, 1. At the conclusion
of the championship the driver with most points is the champion. If there is a tie, champion is the one with most wins (i.e. first places). If a tie still exists, it is chosen the one with most second places, and so on, until there are no more place to use
for compare.

Last year another scoring system was proposed but rejected. In it the champion is the one with most wins. If there is tie, champion is the one with most points. If a tie still exists it is proceeded the same way as in the original scoring system, that is comparing
number of second, third, forth, and so on, places.

You are given the result of all races during the season and you are to determine the champion according to both scoring systems. It is guaranteed, that both systems will produce unique champion.

Input

The first line contain integer t (1 ≤ t ≤ 20),
where t is the number of races. After that all races are described one by one. Every race description start with an integer n (1 ≤ n ≤ 50)
on a line of itself, where n is the number of clasified drivers in the given race. After thatn lines
follow with the classification for the race, each containing the name of a driver. The names of drivers are given in order from the first to the last place. The name of the driver consists of lowercase and uppercase English letters and has length at most 50
characters. Comparing of names should be case-sensetive.

Output

Your output should contain exactly two line. On the first line is the name of the champion according to the original rule, and on the second line the name of the champion according to the alternative rule.

Examples
input
3
3
Hamilton
Vettel
Webber
2
Webber
Vettel
2
Hamilton
Vettel
output
Vettel
Hamilton
input
2
7
Prost
Surtees
Nakajima
Schumacher
Button
DeLaRosa
Buemi
8
Alonso
Prost
NinoFarina
JimClark
DeLaRosa
Nakajima
Patrese
Surtees
output
Prost
Prost

结构体排序
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <map>
#include <string> using namespace std;
int n,m;
struct Node
{
int score;
int r[55];
string name;
}a[1005];
int cmp1(Node a,Node b)
{
if(a.score==b.score)
{
for(int i=1;i<50;i++)
{
if(a.r[i]==b.r[i])
continue;
return a.r[i]>b.r[i];
}
}
return a.score>b.score;
}
int cmp2(Node a,Node b)
{
if(a.r[1]==b.r[1])
{
if(a.score==b.score)
{
for(int i=2;i<50;i++)
{
if(a.r[i]==b.r[i])
continue;
return a.r[i]>b.r[i];
}
}
return a.score>b.score;
}
return a.r[1]>b.r[1];
}
map<string,int> mm; int num[55]={0,25,18,15,12,10,8,6,4,2,1};
int main()
{
scanf("%d",&n);
string s;
int cnt=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&m);
for(int j=1;j<=m;j++)
{
cin>>s;
if(!mm.count(s))
mm[s]=cnt++;
a[mm[s]].score+=num[j];
a[mm[s]].r[j]++;
a[mm[s]].name=s;
}
}
sort(a,a+cnt,cmp1);
cout<<a[0].name<<endl;
sort(a,a+cnt,cmp2);
cout<<a[0].name<<endl;
return 0;
}

最新文章

  1. Arcgis 10.1安装
  2. C语言中链表任意位置怎么插入数据?然后写入文件中?
  3. 【转】VS项目属性的一些配置项的总结
  4. @import与link
  5. unity, itween, closed path
  6. 2016.6.17 计算机网络复习要点之PPP协议
  7. Haskell缩进规则
  8. js执行环境深入研究
  9. apache rewrite rule
  10. 开源 自由 java CMS - FreeCMS1.9 评论管理
  11. C#执行cmd命令
  12. J2EE (九) 静态代理和动态代理--间接“美”
  13. sql注入基础(原理)
  14. tensorflow softplus应用
  15. 如何面对被抛弃的System.Data.OracleClient
  16. 微信小程序--家庭记账本开发--04
  17. Spring配置从配置文件读取属性值
  18. 章节七、6-Map集合的区别
  19. 洛谷P2512 糖果传递
  20. WINCE 下载地址(转)

热门文章

  1. How To run OAI eNB (No S1) with USRP X310(1)
  2. C++不让程序一闪而过
  3. 相似微信的ChattingUi
  4. nyoj 760 See LCS again
  5. Activiti - 新一代的开源 BPM 引擎 (zhuan)
  6. jquery插件-table转Json数据插件
  7. rpc 理解
  8. malloc,我误解你了
  9. python学习笔记(1)--遍历txt文件,正则匹配替换文字
  10. [Linux]Linux应用程序中添加强制中断处理