/*
* Winner.cpp
*
* Created on: 2013-10-13
* Author: wangzhu
*/ /**
* 先找出所有选手的分数和中最大的分数和,之后在所有选手的分数和中看有几个是和最大的分数和相等,
* 1)、若有多个,则比较谁在比赛结束钱分数先达到最大分数和,则是赢家;
* 2)、若只有一个,则直接输出。
*/
#include<cstdio>
#include<iostream>
#include<map>
#include<string.h>
using namespace std;
#define NMAX 1010
struct Node {
int index, val;
char name[];
};
Node node[NMAX];
map<string, int> myMap;
map<string, int> myMap1;
map<string, int>::iterator mapIterator; void find(int n, int nmax) {
int m;
for (int i = ; i < n; i++) {
for (mapIterator = myMap1.begin(); mapIterator != myMap1.end();
mapIterator++) {
if ( == strcmp(node[i].name, mapIterator->first.c_str())) {
// printf("%d %d %s\n", node[i].index, node[i].val, node[i].name);
m = myMap1[mapIterator->first];
m += node[i].val;
myMap1[mapIterator->first] = m;
if (m >= nmax) {
printf("%s\n", node[i].name);
return;
}
}
}
}
} int main() {
freopen("data.in", "r", stdin);
int n, m,nmax;
string nmaxStr;
while (~scanf("%d", &n)) {
myMap.clear();
myMap1.clear(); for (int i = ; i < n; i++) {
scanf("%s%d", node[i].name, &node[i].val);
node[i].index = i;
myMap[node[i].name] +=node[i].val;
}
nmax = -;
for(mapIterator = myMap.begin();mapIterator!=myMap.end();mapIterator++){
if(nmax < mapIterator->second){
nmax = mapIterator->second;
}
}
m = ;
for(mapIterator = myMap.begin();mapIterator!=myMap.end();mapIterator++){
if(nmax == mapIterator->second){
nmaxStr = mapIterator->first;
myMap1[mapIterator->first] = ;
m ++;
}
}
//printf("%d %d\n",m,nmax);
if(m != ){
find(n,nmax);
}else{
printf("%s\n",nmaxStr.c_str());
}
}
return ;
}

codeforces Winner的更多相关文章

  1. codeforces 2A Winner (好好学习英语)

    Winner 题目链接:http://codeforces.com/contest/2/problem/A ——每天在线,欢迎留言谈论. 题目大意: 最后结果的最高分 maxscore.在最后分数都为 ...

  2. CodeForces 2A - Winner(模拟)

    题目链接:http://codeforces.com/problemset/problem/2/A A. Winner time limit per test 1 second memory limi ...

  3. CodeForces 2A Winner

    Winner Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Statu ...

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

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

  5. Codeforces 2A :winner

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

  6. Codeforces Beta Round #2 A. Winner

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

  7. Codeforces Gym100952 A.Who is the winner? (2015 HIAST Collegiate Programming Contest)

      A. Who is the winner?   time limit per test 1 second memory limit per test 64 megabytes input stan ...

  8. Codeforces Round #603 (Div. 2) C. Everyone is a Winner! 二分

    C. Everyone is a Winner! On the well-known testing system MathForces, a draw of n rating units is ar ...

  9. Codeforces Round #603 (Div. 2) C. Everyone is a Winner! (数学)

    链接: https://codeforces.com/contest/1263/problem/C 题意: On the well-known testing system MathForces, a ...

随机推荐

  1. 获取iframe 内元素的方法

    1,原生的方法 首先给iframe 设置 id 属性 var obj = document.getElementById('iframe').contentWindow; setTimeout(fun ...

  2. Java 简单算法--打印回文数字

    package cn.magicdu.algorithm; public class CircleNumber { public static void main(String[] args) { f ...

  3. 【转】prototype扩展的JavaScript常用函数库

    Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ...

  4. [转]第一章 Windows Shell是什么 【来源:http://blog.csdn.net/wangqiulin123456/article/details/7987862】

    一个操作系统外壳的不错的定义是它是一个系统提供的用户界面,它允许用户执行公共的任务,如访问文件系统,导出执行程序,改变系统设置等.MS-DOS有一个Command.COM扮演着这个角色.然而Windo ...

  5. javascript 第28节 jQuery事件、迭代、样式

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

  6. springmvc学习(三)

    第一点---------使用 @RequestMapping 映射请求• Ant 风格资源地址支持 3 种匹配符:?:匹配文件名中的一个字符 *:匹配文件名中的任意字符 **:** 匹配多层路径 @R ...

  7. http数据包解析碰到gzip压缩格式的解压

    其中在做http数据包临控时碰到gzip压缩格式,在网友发布的一些技术文章基础上,经过一段时间的研究.调试,终于解析成功.现将核心代码公布于此,希望能够和大家一起共同学习交流.注:以下代码需要依赖zl ...

  8. JS到PHP使用RSA算法进行加密通讯

    我们平时做用户登录表单提交,用户名密码都是明文直接POST到后端,这样很容易被别人从监听到. 在js上做rsa,感觉jsencrypt这个是封装的比较好的,但用起来还是遇到了些坑,所以踩进代码里填填坑 ...

  9. 让c像python一样可以在命令行写代码并且编译

    在你亲爱的.bashrc/.zshrc中添加 ###C###go_libs="-lm"go_flags="-g -Wall -include allheads.h -O3 ...

  10. Google设计理念

    Google的十大信条 我们首次拟就这“十大信条”还是在Google刚刚成立没几年的时候.此后,我们时常重新审视这份清单,看看它是否依然适用.我们希望这些信条永不过时,而您也可以监督我们是否遵守了这些 ...