很多人玩一个游戏,每一轮有一个人得分或者扣分,最后分数最高的人夺冠;如果最后有多个人分数都是最高的,则这些人里面,在比赛过程中首先达到或者超过这个分数的人夺冠。现在给定最多1000轮每轮的情况,求最后的冠军是谁。

========================================================================================

#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
using namespace std;
typedef long long LL;
const LL INF = 0xffffff;
const int maxn = ;
const LL MOD = 1e9+;
struct node
{
char name[maxn];
int coun;
int sorce;
} P[maxn], ans, Read[maxn];
/// int main()
{
int n, k = , i, j, Max = -INF;
memset(P, , sizeof(P));
ans.sorce = -INF;
cin >> n; for(i=; i<n; i++)
{
cin >> Read[i].name >> Read[i].sorce; for(j=; j<k; j++)
{
if(strcmp(P[j].name, Read[i].name) == )
{
P[j].sorce += Read[i].sorce;
break;
}
} if(j == k)
{
strcpy(P[j].name,Read[i].name);
P[k++].sorce = Read[i].sorce;
}
} for(i=; i<k; i++)
Max = max(P[i].sorce, Max);
k = ;
memset(P, , sizeof(P)); for(i=; i<n; i++)
{
for(j=; j<k; j++)
{
if(strcmp(P[j].name, Read[i].name) == )
{
P[j].sorce += Read[i].sorce;
if(P[j].sorce >= Max && P[j].coun == -)
P[j].coun = i;
break;
}
} if(j == k)
{
strcpy(P[j].name,Read[i].name);
P[k++].sorce = Read[i].sorce;
P[j].coun = -;
if(P[j].sorce >= Max)
P[j].coun = i;
}
} for(i=; i<k; i++)
{
if(ans.sorce < P[i].sorce || (ans.sorce == P[i].sorce && P[i].coun < ans.coun) )
ans = P[i];
} cout << ans.name << endl;
return ;
}

CodeForce 2A Winner的更多相关文章

  1. CodeForces 2A Winner

    Winner Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  2. codeforces 2A Winner (好好学习英语)

    Winner 题目链接:http://codeforces.com/contest/2/problem/A ——每天在线,欢迎留言谈论. 题目大意: 最后结果的最高分 maxscore.在最后分数都为 ...

  3. CodeForces 2A - Winner(模拟)

    题目链接:http://codeforces.com/problemset/problem/2/A A. Winner time limit per test 1 second memory limi ...

  4. Codeforces 2A :winner

    A. Winner time limit per test 1 second memory limit per test 64 megabytes input standard input outpu ...

  5. 红米2A高配刷机记录

    2014816 机型:红米2A高配版 设备型号:2014816 CPU:高通 线刷:fastboot平台 http://192.168.7.118/MesReports/Reports/Cutting ...

  6. HDU 5754 Life Winner Bo 组合博弈

    Life Winner Bo Problem Description   Bo is a "Life Winner".He likes playing chessboard gam ...

  7. HDU 2509 Be the Winner nim博弈变形

    Be the Winner Problem Description   Let's consider m apples divided into n groups. Each group contai ...

  8. mac上执行sed的编辑 -i命令报错sed: 1: "test.txt": undefined label ‘est.txt’或sed: 1: "2a\test\": extra characters after \ at the end of a command

    问题一 sed编辑命令:[sed -i 's/a/b/g' test.txt]   报错:sed: 1: "test.txt": undefined label 'est.txt' ...

  9. HDU5754 Life Winner Bo(博弈)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5754 Description Bo is a "Life Winner" ...

随机推荐

  1. sqlserver 2008表分区操作

    表分区操作步骤 1.设计表进行分区的方案,水平分区.垂直分区 a.水平切割将减少表的行数,这样可以将历史数据归档,减少表大小,提高访问速度. b.垂直切割将分为主表和从表方式,将主要的列字段存放在主表 ...

  2. linux下面安装和配置nginx

    下载nginx-1.0.2.tar.gz wget nginx-1.0.2.tar.gz 解压 nginx-1.0.2.tar.gz tar -xzvf nginx-1.0.2.tar.gz 配置安装 ...

  3. 9.23 noip模拟试题

      Problem 1 抓牛(catchcow.cpp/c/pas) [题目描述] 农夫约翰被通知,他的一只奶牛逃逸了!所以他决定,马上出发,尽快把那只奶牛抓回来. 他们都站在数轴上.约翰在N(O≤N ...

  4. 设计模式学习——准备(UML类图)

    前言 其实吧,最早接触UML是源于软件设计师的考试,半路出家实在难为我了.学设计模式总是要画类图的,所以补充UML的类图的知识是很重要滴.第一篇就偷懒一点copy别人的东西了.实话说,我们都是踩在巨人 ...

  5. Html5新增的语义化标签(部分)

    2014年10月29日,万维网联盟宣布,经过接近8年的艰苦努力,html5的标准规范终于制定完成.这是互联网的一次重大变革,这也许是一个时代的来临! 总结一些h5新增的语义化标签,记录下来方便自己学习 ...

  6. MEF依赖注入调试小技巧!

    自从哥的项目使用MEF以来,天天那个纠结啊,甭提了.稍有错误,MEF就报错,但就不告诉你哪错了,大爷的. 后来看了MEFX的相关调试方法,感觉也不太理想,根本不够直观的看到错误原因,也许是没有深入学习 ...

  7. jetty服务器访问系统的域名

    jetty-env.xml=><Set name="contextPath">/epps-compensation-backend</Set> 这个决 ...

  8. android SDK 代理配置(东北大学)

    启动 Android SDK Manager ,打开主界面,依次选择「Tools」.「Options...」,弹出『Android SDK Manager - Settings』窗口: 在『Andro ...

  9. ResultSetMetaData rsmd = rs.getMetaData()是什么意思?

    ResultSetMetaData rsmt=rs.getMetaData(); 得到结果集(rs)的结构,比如字段数.字段名等.使用rs.getMetaData().getTableName(1)) ...

  10. 文字排版--粗体(font-weight)

    我们还可以使用css样式来改变文字的样式:粗体.斜体.下划线.删除线,可以使用下面代码实现设置文字以粗体样式显示出来. p span{font-weight:bold;} 在这里大家可以看到,如果想为 ...