当前位置:网站首页>7. F1方程式冠军
7. F1方程式冠军
2022-07-26 22:42:00 【lzl_0408】
【问题描述】
一级方程式F1锦标赛由一系列称为大奖赛的分站赛组成。每一场比赛的车手都根据他们的最后位置获得积分。只有前10名车手按以下顺序获得分数:25、18、15、12、10、8、6、4、2、1。在锦标赛结束时,得分最多的车手是冠军。如果有平分,则冠军是赢的最多的人(即排位第一)。如果还是平分,则选择得到排位第二最多的人,依此类推,直到没有更多的排位进行比较。
后来又提出了另一个得分制度,其中冠军是赢的最多的。如果有平手,冠军是得分最多的。如果仍然存在平手,则按原来的得分制度进行,即比较第二、第三、第四、...排位的次数。
在本赛季,你会得到所有比赛的结果,你将根据两个得分系统来分别确定冠军。数据保证两套系统都能得到唯一的冠军。
【输入形式】
第一行一个整数t(1<=t<=20),t是分站赛的场次数。之后是每个分站赛的最终排位情况,每个的第一行一个整数n(1<=n<=100)表示排位车手人数,之后n行按排位列出车手的名字,排位从第一到最后,车手的名字为长度不超过50的英文字符,大小写区分。
【输出形式】、
输出为两行,第一行为按照原始规则确定的冠军,第二行是按照可选规则确定的冠军。
【样例输入】
3
3
apple
banana
pear
2
pear
banana
2
apple
banana
【样例输出】
banana
apple
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
struct Competition
{
string name;
int num[101]={0};
int score=0;
};
bool comp1(Competition a,Competition b)
{
if(a.score!=b.score)
return a.score>b.score;
else
{
for(int i=1;i<=100;i++)
{
if(a.num[i]!=b.num[i])
return a.num[i]>b.num[i];
}
}
}
bool comp2(Competition a,Competition b)
{
if(a.num[1]!=b.num[1])
return a.num[1]>b.num[1];
else if(a.num[1]==b.num[1])
return a.score>b.score;
else
{
for(int i=2;i<=10;i++)
{
if(a.num[i]!=b.num[i])
return a.num[i]>b.num[i];
}
}
}
int main()
{
Competition comer[101];
int n;
cin>>n;
map<string,int> maps;
int remark=0;
while(n--)
{
int m;
cin>>m;
for(int i=1;i<=m;i++)
{
string str;
cin>>str;
if(maps.find(str)==maps.end())
{
comer[remark].name=str;
maps[str]=remark;
remark++;
}
int p=maps[str];
comer[p].num[i]++;
if(i==1)
comer[p].score+=25;
if(i==2)
comer[p].score+=18;
if(i==3)
comer[p].score+=15;
if(i==4)
comer[p].score+=12;
if(i==5)
comer[p].score+=10;
if(i==6)
comer[p].score+=8;
if(i==7)
comer[p].score+=6;
if(i==8)
comer[p].score+=4;
if(i==9)
comer[p].score+=2;
if(i==10)
comer[p].score+=1;
}
}
sort(comer,comer+remark,comp1);
cout<<comer[0].name<<endl;
sort(comer,comer+remark,comp2);
cout<<comer[0].name<<endl;
return 0;
}
边栏推荐
- Android -- basic usage of litepal database framework
- Hidden index and descending index in MySQL 8.0 (new feature)
- 数据仓库知识点
- SQL学习(2)——表的基础查询与排序
- Flink1.11 SQL local run demo & local webui visual solution
- Flink based real-time computing Demo - Data Analysis on user behavior
- MySQL index optimization: scenarios where the index fails and is not suitable for indexing
- Programming method of sparksql
- MYSQL中的行锁升级表锁的原因
- Data warehouse knowledge points
猜你喜欢

Flink1.11 SQL local run demo & local webui visual solution

Android -- basic usage of litepal database framework

Use and cases of partitions

Neo4j基础指南(安装,节点和关系数据导入,数据查询)

基于Flink实时计算Demo—关于用户行为的数据分析

One of the Flink requirements - sideoutput (Application of side output flow: output the temperature higher than 30 ℃ to the mainstream, and output the temperature lower than 30 ℃ to the side flow)

Android——LitePal数据库框架的基本用法

What are the necessary functions of short video app development?

基于Flink实时项目:用户行为分析(三:网站总浏览量统计(PV))

李宏毅机器学习(2017版)_P6-8:梯度下降
随机推荐
VIS工作流 - PlantCV
Kubernetes 是什么 ?
Android——LitePal数据库框架的基本用法
李宏毅机器学习(2017版)_P13:深度学习
What is kubernetes?
Flink based real-time project: user behavior analysis (II: real-time traffic statistics)
FlinkSql多表(三表) join/interval join
Flink Interval Join源码理解
李宏毅机器学习(2017版)_P6-8:梯度下降
Write the changed data in MySQL to Kafka through flinkcdc (datastream mode)
The shortest way to realize video applets: from bringing goods to brand marketing
李宏毅机器学习(2017版)_P21:卷积神经网络CNN
网站日志采集和分析流程
MySQL8.0中的隐藏索引和降序索引(新特性)
Spark On YARN的作业提交流程
Flink1.11 多并行度watermark测试
Spark source code learning - Data Serialization
MySQL索引优化:索引失效以及不适合建立索引的场景
Golang implements AES with five encryption mode functions, encrypt encryption and decryption string output
SQL学习(2)——表的基础查询与排序