题目链接:http://codeforces.com/problemset/problem/2/A

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 <cstdio>
#include <iostream>
#include <map>
using namespace std;
map<string, int> a,b;
string s[1017]; int main()
{
int x[1017];
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> s[i] >> x[i];
a[s[i]]+=x[i];
}
int maxx = 0;
for(int i = 1; i <= n; i++)
{
if(a[s[i]] > maxx)
maxx = a[s[i]];
} for(int i = 1; i <= n; i++)
{
b[s[i]]+=x[i];
if((b[s[i]]>=maxx) && (a[s[i]]>=maxx))//在终于分数是最大的人中,选首先达到最大分数的人
{
cout << s[i];
break;
}
}
return 0;
}

CodeForces 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

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

  4. Codeforces 389B(十字模拟)

    Fox and Cross Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submi ...

  5. codeforces 591B Rebranding (模拟)

    Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...

  6. Codeforces 626B Cards(模拟+规律)

    B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...

  7. Codeforces 631C. Report 模拟

    C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...

  8. Codeforces 679B. Barnicle 模拟

    B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...

  9. CodeForces 382C【模拟】

    活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsig ...

随机推荐

  1. 2017-2018-1 JAVA实验站 冲刺 day02

    2017-2018-1 JAVA实验站 冲刺 day02 各个成员今日完成的任务 小组成员 今日工作 完成进度 张韵琪 写博客.进行工作总结 100% 齐力锋 找背景音乐.开始界面图片.按钮图片.按钮 ...

  2. Python 温度转换实例分析

    #TempConvert.py Tempstr=input('请输入要转换的温度值:') if Tempstr[-1] in ['C','c']: F=1.8*eval(Tempstr[0:-1])+ ...

  3. [转]jquery加载页面的方法(页面加载完成就执行)

    jquery加载页面的方法(页面加载完成就执行),建议大家看下windows.onload与$(document).ready之间的区别.   1.$(function(){ $("#a&q ...

  4. mybatis源码分析(8)-----事务(mybatis管理、spring管理)

    写在前面 接口:MyBatis的事务Transaction的接口有一下实现类 JdbcTransaction 由jdbc管理的事务(即利用Connection对象完成对事务的提交(commit()). ...

  5. 查找可用的谷歌IP地址

    在终端下运行命令就可以: nslookup www.google.cn 就可以找到

  6. 传输层TCPUDP 具体解释

    1.传输层存在的必要性 因为网络层的分组传输是不可靠的,无法了解数据到达终点的时间,无法了解数据未达终点的状态.因此有必要增强网络层提供服务的服务质量. 2.引入传输层的原因 面向连接的传输服务与面向 ...

  7. Curvilinear structure detections

    此部分参考处 As a structure-based detector, PCBR does not use edges, instead, it uses curvilinear structur ...

  8. WebView 加载网页和java 与js交互

    [mw_shl_code=java,true]WebView是一个可以显示网页的控件.需求:通过WebView加载assets下的html文件.实现页面的缩放.向menu键添加:前进.后退和刷新,实现 ...

  9. gitignore不起作用解决的方法

    前面有文章介绍了使用gitignore文件的方法,该文件表示过滤规则,可是对已经增加版本号库的文件不能生效,因此须要利用命令将想要忽略的文件从版本号库中删除,比方说.我们对androidproject ...

  10. android中共享全局数据的方法

    转自:http://blog.csdn.net/ameyume/article/details/6100756 我们在平时的开发中,有时候可能会需要一些全局数据,来让应用中的所有Activity和Vi ...