Codeforces Beta Round #2 A. Winner
1 second
64 megabytes
standard input
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.
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.
Print the name of the winner.
3
mike 3
andrew 5
mike 2
andrew
3
andrew 3
andrew 2
mike 5
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的更多相关文章
- Codeforces Beta Round #2 A. Winner 水题
A. Winner 题目连接: http://www.codeforces.com/contest/2/problem/A Description The winner of the card gam ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- 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]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
随机推荐
- 与你相遇好幸运,Waterline的属性
>支持的数据类型: string / text / integer / float / date / time / datetime / boolean / binary / array / j ...
- gbdt可视化
gbdt的最大优点,和决策树一样,高度可解释,最喜欢的分类模型:) #!/usr/bin/env python #coding=gbk # ============================== ...
- Android浏览本地 API文档 + 解决页面加载慢的问题
火狐浏览器安装离线浏览插件: 用浏览器打开index.html文件,你会发现加载的很慢,原因你懂的,为此,我们可以通过离线的方式 查看本地API文档,用火狐浏览器 + Work Offline插 ...
- Delphi字符串与字符数组之间的转换(初始化的重要性)
紧接着上篇博客讲解的内容: 将Char型数组转换为string类型还有下面的这种方法 但是我在测试的时候遇到了一些问题,并在下面进行了解释和总结 先说出我的总结 其实我们在学习编程的时候(比如我之前学 ...
- [译]关于.NET Core1.1的通告
以下翻译可能会有不准确的地方, 想看原文的童鞋移步到Announcing .NET Core 1.1, 微软的开源真心喜欢, 希望有更多的童鞋关注微软, 关注.NET Core 我们很兴奋地宣布.NE ...
- hdu 2516 FIB博弈
分析请看:cxlove #include<iostream> #include<cstdio> #include<cstring> #include<algo ...
- ARM伪指令,王明学learn
ARM伪指令 在ARM汇编语言程序中里,有一些特殊指令助记符与指令系统的助记符不同,没有相对应的操作码,通常称这些特殊指令助记符为伪指令,他们所完成的操作称为伪操作.伪指令在元程序中的作用是为完成汇编 ...
- 有关servlet初学者的资源和建议
四天来学习servlet是很痛苦的经历,其实可以不必要这么痛苦,关键是一定要学会冷静的分析问题与解决问题,要不言学习也没有那么多的乐趣.初学java刚满15天. 首先对于资源来说建议先读一点点的PPT ...
- apache服务器安装
下载地址:http://www.apachehaus.com/cgi-bin/download.plx 全程按这篇来的,很顺利 http://www.cnblogs.com/yerenyuan/p/5 ...
- Linux学习笔记(14)文件系统管理
1 回顾分区与系统 (1)分区类型 Linux的分区一般包括主分区,扩展分区和逻辑分区.其中: 主分区最多只能分4个: 扩展分区只能有一个,也算作主分区的一种,即主分区加扩展分区最多有4个.但扩展分区 ...