CodeForces 24B F1 Champions(排序)
2 seconds
256 megabytes
standard input
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.
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.
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.
3
3
Hamilton
Vettel
Webber
2
Webber
Vettel
2
Hamilton
Vettel
Vettel
Hamilton
2
7
Prost
Surtees
Nakajima
Schumacher
Button
DeLaRosa
Buemi
8
Alonso
Prost
NinoFarina
JimClark
DeLaRosa
Nakajima
Patrese
Surtees
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(排序)的更多相关文章
- 24B F1 Champions
传送门 题目 Formula One championship consists of series of races called Grand Prix. After every race driv ...
- Codeforces 510C (拓扑排序)
原题:http://codeforces.com/problemset/problem/510/C C. Fox And Names time limit per test:2 seconds mem ...
- E - E CodeForces - 1100E(拓扑排序 + 二分)
E - E CodeForces - 1100E 一个n个节点的有向图,节点标号从1到n,存在m条单向边.每条单向边有一个权值,代表翻转其方向所需的代价.求使图变成无环图,其中翻转的最大边权值最小的方 ...
- CodeForces 721C Journey(拓扑排序+DP)
<题目链接> 题目大意:一个DAG图有n个点,m条边,走过每条边都会花费一定的时间,问你在不超过T时间的条件下,从1到n点最多能够经过几个节点. 解题分析:对这个有向图,我们进行拓扑排序, ...
- 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 ...
- Selling Souvenirs CodeForces - 808E (分类排序后DP+贪心)
E. Selling Souvenirs time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Cinema CodeForces - 670C (离散+排序)
Moscow is hosting a major international conference, which is attended by n scientists from different ...
- CodeForces - 589B(暴力+排序)
Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n ...
- CodeForces - 919D Substring (拓扑排序+dp)
题意:将一个字符串上的n个字符视作点,给出m条有向边,求图中路径上最长出现的相同字母数. 分析:首先如果这张图中有环,则可以取无限大的字符数,在求拓扑排序的同时可以确定是否存在环. 之后在拓扑排序的结 ...
随机推荐
- 对象.delegate=self的理解
整理自:http://www.cocoachina.com/ask/questions/show/87430 各位大神,对象.delegate=self是啥意思,委托的意思不就是自己的任务交给其他人去 ...
- html中iframe子页面与父页面元素的访问以及js变量的访问
1.子页面访问父页面元素 parent.document.getElementById('id')和document相关的方法都可以这样用 2.父页面访问子页面元素 document.ge ...
- 漫谈Linux下的音频问题(转)
转自 http://www.kunli.info/2009/03/24/linux-sound-issue/ 现今的互联网,比较Linux和Windows的战争贴基本都成月经贴了.一群群激进的用户不断 ...
- zend server 和zend studio 最佳实践
1.zend server 安装好后需要重启下.无论是win还是mac..win不重启组件不能用.mac 不重启守护进程是离线的 2.修改apache配置.的根目录.到zendstudio的工作空间 ...
- javaweb reponse 写出文件
Map map = getSearchValue(); File excelFile = orderService.getexportexcel(id,map); InputStream is = n ...
- Spring MVC添加支持Http的delete、put请求!(HiddenHttpMethodFilter)
浏览器form表单只支持GET与POST请求,而DELETE.PUT等method并不支持,spring3.0添加了一个过滤器,可以将这些请求转换为标准的http方法,使得支持GET.POST.PUT ...
- C语言 · 完数
算法训练 完数 时间限制:1.0s 内存限制:512.0MB 问题描述 一个数如果恰好等于它的因子之和,这个数就称为“完数”.例如,6的因子为1.2.3,而6=1+2+3,因此6就是 ...
- QT 5.7.0 移植之 tslib 编译配置
QT5.7 编译请参考:http://www.cnblogs.com/chenfulin5/p/5798764.html 最新的 tslib 是从他的 github 下载下来的. 地址是:https: ...
- linphone 调试信息
root@phyCORE-AM335x:~ linphonec -V -d 6INFO: no logfile, logging to stdoutortp-message-oRTP-0.20.0 i ...
- 数据库 Oracle数据库对象一
常见的数据库对象 表:基本的数据存储集合,由行和列组成 视图:从表中抽出的逻辑上相关的数据集合 序列:提供有规律的数值 索引:提高查询的效率 同义词:给对象起别名 create table语句 --c ...