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;
}

CodeForces 24B F1 Champions(排序)的更多相关文章

  1. 24B F1 Champions

    传送门 题目 Formula One championship consists of series of races called Grand Prix. After every race driv ...

  2. Codeforces 510C (拓扑排序)

    原题:http://codeforces.com/problemset/problem/510/C C. Fox And Names time limit per test:2 seconds mem ...

  3. E - E CodeForces - 1100E(拓扑排序 + 二分)

    E - E CodeForces - 1100E 一个n个节点的有向图,节点标号从1到n,存在m条单向边.每条单向边有一个权值,代表翻转其方向所需的代价.求使图变成无环图,其中翻转的最大边权值最小的方 ...

  4. CodeForces 721C Journey(拓扑排序+DP)

    <题目链接> 题目大意:一个DAG图有n个点,m条边,走过每条边都会花费一定的时间,问你在不超过T时间的条件下,从1到n点最多能够经过几个节点. 解题分析:对这个有向图,我们进行拓扑排序, ...

  5. Divide by three, multiply by two CodeForces - 977D (思维排序)

    Polycarp likes to play with numbers. He takes some integer number xx, writes it down on the board, a ...

  6. Selling Souvenirs CodeForces - 808E (分类排序后DP+贪心)

    E. Selling Souvenirs time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  7. Cinema CodeForces - 670C (离散+排序)

    Moscow is hosting a major international conference, which is attended by n scientists from different ...

  8. CodeForces - 589B(暴力+排序)

    Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n ...

  9. CodeForces - 919D Substring (拓扑排序+dp)

    题意:将一个字符串上的n个字符视作点,给出m条有向边,求图中路径上最长出现的相同字母数. 分析:首先如果这张图中有环,则可以取无限大的字符数,在求拓扑排序的同时可以确定是否存在环. 之后在拓扑排序的结 ...

随机推荐

  1. 32位嵌入式微处理器(processor)一览

    32位嵌入式微处理器(processor)一览 由于嵌入式系统的专用型与定制性,与全球PC市场不同,没有一种微处理器或者微处理器公司可以主导嵌入式系统.本文分析了当前市场上主流的一些32位嵌入式微处理 ...

  2. [svc]salt基本原理

    转载自:来自:http://tech.mainwise.cn/?p=438 说明:salt是一个异构平台基础设置管理工具(虽然我们通常只用在Linux上),使用轻量级的通讯器ZMQ,用Python写成 ...

  3. 从调试角度理解ActionContext、OgnlContext、OgnlValueStack的关系

    被调试代码:    package web; import java.util.Map; import javax.servlet.http.HttpServletRequest; import or ...

  4. linux中录屏工具byzanz

    linux中录屏工具byzanz: 1.安装 sudo apt install byzanz 2.使用 help:byzanz-record --help 配合xwininfo使用--xwininfo ...

  5. 使用【单独】的一个<script>进行js文件的引用

    刚才用jQuery的时候,总是发现js代码不被执行...后来发现我的代码是这么写的: <script type="text/javascript" src="htt ...

  6. na+mb与gcd

    蒜头君和花椰妹在玩一个游戏,他们在地上将 nn 颗石子排成一排,编号为 11 到 nn.开始时,蒜头君随机取出了 22 颗石子扔掉,假设蒜头君取出的 22 颗石子的编号为 aa, bb.游戏规则如下, ...

  7. BAT-把当前用户以管理员权限运行

    相关资料: http://jingyan.baidu.com/article/72ee561a5dc24fe16138df95.html 网友求助:联想Y400,Win8系统 怎样获得管理员身份 要求 ...

  8. wifi设置

    1 编辑/etc/init.d/wifi #!/bin/sh case "$1" in start)     echo /sbin/mdev > /proc/sys/kern ...

  9. 第二百六十一节,Tornado框架模板引擎本质

    Tornado框架模板引擎本质 只需要了解一下即可 本篇就来详细的剖析模板处理的整个过程. 上图是返回给用户一个html文件的整个流程,较之前的Demo多了绿色流线的步骤,其实就是把[self.wri ...

  10. 以上过程为实现equals的标准过程

    以下为定义equal(加上这个定义,返回ture或false) public boolean equals(Object o){ student s=(student)o; if (s.name.eq ...