很多人玩一个游戏,每一轮有一个人得分或者扣分,最后分数最高的人夺冠;如果最后有多个人分数都是最高的,则这些人里面,在比赛过程中首先达到或者超过这个分数的人夺冠。现在给定最多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. Iterator<Entry<String,String>> iter=map.entrySet().iterator(); 是什么意思

    //获得map的迭代器,用作遍历map中的每一个键值对Iterator是迭代器,map之前应该定义过,姑且认为是HashMap.<Entry<String,String>>表示 ...

  2. CSS3 颜色值HSL表示方式&简单实例

    HSL色彩模式:就是色调(Hue).饱和度(Saturation).亮度(Lightness)三个颜色通道的改变以及它们相互之间的叠加来获得各种颜色,色调(Hue)色调最大值360,饱和度和亮度有百分 ...

  3. sql-从查询结果创建一个永久表

    语法: select x into new_tableName  from ori_tableName 例如: SELECT [site] ,[day] ,[val]/31.4 [val] into ...

  4. 项目中常用SQL语句总结

    1.项目中常常需要修改字段长度,但需要保留数据--增加业务受理 项目名称 字段长度alter table t_ywsl add aa varchar2(200);update t_ywsl set a ...

  5. 文字排版--字体(font-family)

    我们可以使用css样式为网页中的文字设置字体.字号.颜色等样式属性.下面我们来看一个例子,下面代码实现:为网页中的文字设置字体为宋体. body{font-family:"宋体"; ...

  6. npm不能安装任何包,报错:npm WARN onload-script failed to require onload script npm-autoinit/autoinit及解决方法

    想要利用Hexo搭建一个博客,但是安装时npm一直报错,不仅仅是Hexo包,连别的其他包也不行,会提示下面的一堆错误 npm WARN onload-script failed to require ...

  7. 执行hadoop fs -ls时出现错误RuntimeException: core-site.xml not found

    由于暴力关机,Hadoop fs -ls 出现了下图问题: 问题出现的原因是下面红框框里面的东西,我当时以为从另一个节点下载一个conf.cloudera.yarn文件就能解决问题,发现不行啊,于是删 ...

  8. asp.net 网站和asp.net Web 应用程序的一处不同

    环境为:VS2008Team+.net3.5 asp.net 网站前台页面<%= %>这样绑定可以,asp.net Web 应用程序就不可以 示例代码如下: 1.asp.net网站 < ...

  9. SGU 199 Beautiful People(DP+二分)

    时间限制:0.25s 空间限制:4M 题意: 有n个人,每个人有两个能力值,只有一个人的两个能力都小于另一个的能力值,这两个人才能共存,求能同时共存的最大人数. Solution: 显然这是一个两个关 ...

  10. python3 读写excel

    一直认为python3可以很快的实现很多简单的功能,今天要读excel表格数据,想来很简单,网上一搜,用xlrd即可,然后很多人给出了不同的版本,号称xlrd3,实际上官网一看,xlrd0.9.4兼容 ...