A. Winner
time limit per test

1 second

memory limit per test

64 megabytes

input

standard input

output

standard output

The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a player gains or loses a particular number of points. In the course of the game the number of points is registered in the line "name score", where name is a player's name, and score is the number of points gained in this round, which is an integer number. If score is negative, this means that the player has lost in the round. So, if two or more players have the maximum number of points (say, it equals to m) at the end of the game, than wins the one of them who scored at least m points first. Initially each player has 0 points. It's guaranteed that at the end of the game at least one player has a positive number of points.

Input

The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer number between -1000 and 1000, inclusive.

Output

Print the name of the winner.

Sample test(s)
Input
3
mike 3
andrew 5
mike 2
Output
andrew
Input
3
andrew 3
andrew 2
mike 5
Output
andrew

此题不大好懂,就是要你求出最大分数而且最先得到这个最高分的那个人的名字

思路: 第一步: 我们先求出所有人的最终得分
第二步: 我们求出最终得分的最高分:
第三部: 我们求出第一个得到最高分,而且最终得分也是最高分的那个人,那必定是最先出现的那个人..... 代码:
 #include<iostream>
#include<map>
using namespace std;
struct node
{
int score;
string name;
}ss[];
int main(){ string winner;
int n,maxsc;
map<string ,int>str;
//freopen("test.in","r",stdin);
while(cin>>n){
if(!str.empty()) str.clear();
for(int i=;i<n;i++){ //求出最终态势
cin>>ss[i].name>>ss[i].score;
str[ss[i].name]+=ss[i].score;
}
//求出最大的值
maxsc=str[ss[].name];
for(int i=;i<n;i++){
if(maxsc<str[ss[i].name]){
maxsc=str[ss[i].name];
}
}
map<string ,int>check; //这个表示过程态势
for(int i=;i<n;i++){
check[ss[i].name]+=ss[i].score;
if(check[ss[i].name]>=maxsc&&str[ss[i].name]>=maxsc){
winner=ss[i].name;
break;
}
}
cout<<winner<<endl;
}
return ;
}

cf------(round 2)A. Winner的更多相关文章

  1. CF Round #551 (Div. 2) D

    CF Round #551 (Div. 2) D 链接 https://codeforces.com/contest/1153/problem/D 思路 不考虑赋值和贪心,考虑排名. 设\(dp_i\ ...

  2. CF Round #510 (Div. 2)

    前言:没想到那么快就打了第二场,题目难度比CF Round #509 (Div. 2)这场要难些,不过我依旧菜,这场更是被\(D\)题卡了,最后\(C\)题都来不及敲了..最后才\(A\)了\(3\) ...

  3. UOJ #30. [CF Round #278] Tourists

    UOJ #30. [CF Round #278] Tourists 题目大意 : 有一张 \(n\) 个点, \(m\) 条边的无向图,每一个点有一个点权 \(a_i\) ,你需要支持两种操作,第一种 ...

  4. 竞赛题解 - CF Round #524 Div.2

    CF Round #524 Div.2 - 竞赛题解 不容易CF有一场下午的比赛,开心的和一个神犇一起报了名 被虐爆--前两题水过去,第三题卡了好久,第四题毫无头绪QwQ Codeforces 传送门 ...

  5. 【前行&赛时总结】◇第4站&赛时9◇ CF Round 513 Div1+Div2

    ◇第4站&赛时9◇ CF Round 513 Div1+Div2 第一次在CF里涨Rating QWQ 深感不易……作blog以记之 ( ̄▽ ̄)" +Codeforces 的门为你打 ...

  6. CF Round #600 (Div 2) 解题报告(A~E)

    CF Round #600 (Div 2) 解题报告(A~E) A:Single Push 采用差分的思想,让\(b-a=c\),然后观察\(c\)序列是不是一个满足要求的序列 #include< ...

  7. CF Round #580(div2)题解报告

    CF Round #580(div2)题解报告 T1 T2 水题,不管 T3 构造题,证明大约感性理解一下 我们想既然存在解 \(|a[n + i] - a[i]| = 1\) 这是必须要满足的 既然 ...

  8. CF round #622 (div2)

    CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...

  9. Codeforces Beta Round #2 A. Winner

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

  10. cf Round#273 Div.2

    题目链接,点击一下 Round#273 Div.2 ================== problem A Initial Bet ================== 很简单,打了两三场的cf第一 ...

随机推荐

  1. Mac功夫——OS X应用技巧

    看过不少文章说Mac是了不起的先进操作系统,爱折腾的我,经不住诱惑,也玩起了Mac,用惯了Windows,突然换到Mac下还真是十分不习惯,就连复制粘贴这种简单操作也觉得很是别扭. 用过一段时间才感觉 ...

  2. CentOS 7下编译FreeSWITCH 1.6

    安装背景: 已经最小化安装CentOS 7. 准备工作: 挂载安装光盘,配置yum本地化安装,配置方法可以参考http://www.cnblogs.com/yoyotl/p/4877439.html. ...

  3. mysql数据小姿势

    CREATE TABLE `information` (  `NUMBER` bigint(20) NOT NULL AUTO_INCREMENT,//将number设为自增字段  `USER_NAM ...

  4. Android 测试工具

    有时候会发现给手机烧入的信息里少了某一些文件,比如一个图标,或者一个mp3文件之类的等等,为此做了一个小工具检查指定手机里面是否包含相应的文件. 通过程序执行手机的命令来操作手机,感觉还挺有意思的. ...

  5. linux配置IP地址

    1. ifconfig命令临时配置IP地址 ifconfig命令:查看与配置网络状态命令 如:  ifconfig eht0 192.168.0.200 netmask 255.255.255.0 # ...

  6. hdu 1700 Points on Cycle(坐标旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...

  7. hdu 1800 (map)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/ ...

  8. EditPlus添加到右键菜单

    1.Alt+R 键打开“运行” 2.“运行”中输入:regedit 打开注册表    (1.在 "我的电脑HKEY_CLASSES_ROOT*" 下新建项 shell: (2.在 ...

  9. Python面向对象入门

    http://www.math.pku.edu.cn/teachers/qiuzy/ds_python/courseware/ 这本书的第二章写的是抽象数据类型和Python类 以前从没想过认真的去写 ...

  10. WPF GroupBox样式

    来源:http://code.msdn.microsoft.com/WPF-GroupBox-Style-1d9df7c5/ 效果: XAML CODE: <Window xmlns=" ...