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.

Examples
input
3
mike 3
andrew 5
mike 2
output
andrew
input
3
andrew 3
andrew 2
mike 5
output
andrew

MAP的初体验 map还是很好用的。

#include <bits/stdc++.h>
using namespace std;
string s[];
int i,m,n,o[];
map<string,int>p,t;
int main()
{
cin>>n;
for(i=;i<n;i++)
{
cin>>s[i]>>o[i];
p[s[i]]+=o[i];
}
for(i=;i<n;i++)
m=max(m,p[s[i]]);
for(i=;i<n;i++)
if(p[s[i]]>=m&&(t[s[i]]+=o[i])>=m)
break;
cout<<s[i]<<endl;
return ;
}

Codeforces Beta Round #2 A. Winner的更多相关文章

  1. Codeforces Beta Round #2 A. Winner 水题

    A. Winner 题目连接: http://www.codeforces.com/contest/2/problem/A Description The winner of the card gam ...

  2. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  3. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  4. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  5. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  6. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  7. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  9. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

随机推荐

  1. "".equals(str)和str.equals("")的区别

    如果当str为null的话 "".equals(str)不会报空指针异常,而str.equals("")会报异常.这种方式主要用来防止空指针异常

  2. JQ JSON数据类型

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. Java -- 访问控制

    原文:http://www.cnblogs.com/diyingyun/archive/2011/12/21/2295947.html 可见/访问性 在同一类中 同一包中 不同包中  同一包子类中  ...

  4. 线性代数 -- Linear Algebra with Applications

    @.如果线性方程组无解,则称该方程组是不相容的(inconsistent). @.如果线性方程组至少存在一个解,则称该方程组是相容的(consistent). @.等价方程组(equivalent s ...

  5. MVC – 6.控制器 Action方法参数与返回值

      6.1 Controller接收浏览器数据   a.获取Get数据 : a1:获取路由url中配置好的制定参数: 如配置好的路由: 浏览器请求路径为: /User/Modify/1 ,MVC框架获 ...

  6. uploadify文件批量上传

    uploadify能够时间文件的批量上传,JS文件包下载地址,使用说明可以参考官网文档(http://www.uploadify.com/documentation/) 使用方法如下代码: $(&qu ...

  7. 解决mysql无法插入中文数据及插入后显示乱码的问题

    (1)废话不多说就是使用mysql数据库的时候无法输入中文,可以输入中文后显示的又是乱码!! (2开始解决问题: 第一步:找到安装mysql的目录找到 my.ini 文件: 第二步:使用记事本打开my ...

  8. 跨平台C的IDE

    1.JetBrains的新跨平台C++ IDE,CLion已经开始EAP了,不过这货是收费的 http://confluence.jetbrains.com/display/CLION/Early+A ...

  9. Ubuntu下Chromium for Android 源码的编译

    转自:http://blog.csdn.net/leer168/article/details/9146689 一.环境Ubuntu10.4.4 -desktop-amd64 + VMware Wor ...

  10. 安卓app设计规范整理和Android APP设计篇(转)

    随着安卓智能手机不停的更新换代.安卓手机系统越来越完美,屏幕尺寸也越来越大啦!比如最近小米的miui 6的发布和魅族手机系统的更新等等. 以小米MIUI6的安卓手机来说,MIUI6进行了全新设计,坚持 ...