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 ;
}

最新文章

  1. Python列表去重
  2. 每秒执行一个shell脚本(转载)
  3. JSP 页面缓存以及清除缓存
  4. [转]Ubuntu下使用Jni开发例子
  5. poj1236(强连通缩点)
  6. 2015 Multi-University Training Contest 6
  7. mysql基础篇-----mysql简介
  8. Oracle中Union与Union All的区别(适用多个数据库)
  9. Xcode中Groups和Folder的区别
  10. 原生aspx页面如何引用公共js和css
  11. Unity TimeLine
  12. Java并发编程学习:volatile关键字解析
  13. DOCKER 是什么?!
  14. 用Github做一个静态网页(GithubPages)
  15. 新版TeamTalk部署教程
  16. .net面试题[转载]
  17. MVC之Ajax如影随行
  18. Python center() 方法
  19. .net 微信支付(公众号支付)遇到的问题
  20. Mac下布置appium环境

热门文章

  1. SQL Server 索引和表体系结构(非聚集索引)
  2. python方法中的self
  3. Oracle在线重定义DBMS_REDEFINITION 普通表—&gt;分区表
  4. 五小步让VS Code支持AngularJS智能提示
  5. linux后台查看共享内存和消息队列的命令
  6. itextpd f生成 pdf 文件
  7. UIGrid/UITable 性能优化
  8. mvc5+ef6+Bootstrap 项目心得--WebGrid
  9. 在每次request请求时变化session
  10. C++十进制转换为二进制
  11. SQL Server数据库PIVOT函数的使用详解(一)
  12. easyui 添加dialog
  13. C语言(2)--数据类型
  14. EXT.NET高效开发(三)——使用Chrome浏览器的开发人员工具
  15. 如何写SysV服务管理脚本
  16. LuceneNet 实现快速大文件大数据查询
  17. 记录python接口自动化测试--利用unittest生成测试报告(第四目)
  18. Apache 配置小技巧
  19. JS之函数实际参数转换成数组的方法[].slice.call(arguments)
  20. Thinkphp的S缓存用法!