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. atitit..主流 浏览器 js 引擎 内核 市场份额 attialx总结vOa9

    atitit..主流 浏览器 js 引擎  内核 市场份额 attialx总结vOa9 1. 浏览器内核 1 2. 浏览器的主要组件包括: 2 2.1. 主要组件体系结构 2 2.2. WebCore ...

  2. sql server 列修改null 变成not null

    ALTER TABLE [table_name] ALTER COLUMN [column_name] [datetime] NOT NULL --datetime是列的类型

  3. C++ 简单的日志类

    用法如下: #include "EasyLog.h" int main(){ EasyLog::Inst()->Log("Run..."); } 不只是m ...

  4. Mac下Selenium无法最大化Chrome解决方案

    在用Selenium做自动化操作时,一般最大化浏览器的代码都是:driver.manage().window().maximize(), 但是在Mac下这样是无法最大化Chrome浏览器的,解决方法: ...

  5. SAP ERP 6.0 EHP7 SR2(WINDOWS MSSQL版)安装说明

    原文 by 枫竹丹青 ⋅ 1.安装准备 1.1.版本说明 本文是描述在一个Windows虚拟机.SQL Server数据库环境下,安装SAP ERP 6.0 EHP7 SR2服务器,安装完成虚拟机文件 ...

  6. private继承的作用

    这里有个demo,里面的Stack<T*> : private Stack<void *>,作者对此的解释如下 The partial specialization for o ...

  7. 跟着百度学PHP[13]-文件处理 文件后缀验证、设置随机文件名....

    目录: 文件的处理:00x1 判断错误 文件的处理:00x2 判断类型 文件的处理:00x3 文件大小 ++++++++++++++++++++++++++++++++++++++++++++++++ ...

  8. 一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。

    // test14.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> #include< ...

  9. linux 链接的使用 创建和删除符号连接(软、硬链接)

    1 . 使用方式 :ln [option] source_file dist_file   (source_file是待建立链接文件的文件,dist_file是新创建的链接文件)            ...

  10. 解决异常:Package should contain a content type part [M1.13]

    http://blog.csdn.net/llwan/article/details/8890190 ————————————————————————————————————————————————— ...