/*
* 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. tlb,tlh,tli文件的关系

    tlb文件:com类型库文件.在需要使用对应com类的模块里,“#import ...*.tlb”使用之. tlh.tli文件:他们是vc++编译器解析tlb文件生成的标准c++文件.因为odl和tl ...

  2. SQL Server调优系列进阶篇 - 深入剖析统计信息

    前言 经过前几篇的分析,其实大体已经初窥到SQL Server统计信息的重要性了,所以本篇就要祭出这个神器了. 该篇内容会很长,坐好板凳,瓜子零食之类... 不废话,进正题 技术准备 数据库版本为SQ ...

  3. pdf压缩之GSview

    今天实验室一个同学在网上投简历,网站要求投稿的简历pdf文件必须在100K以内.简历用的是ModernCV的模板,无论如何设置都在160k左右. 尝试用acrobat的压缩功能,也不能保证在100K以 ...

  4. (二)JAVA使用POI操作excel

    1,创建一个时间格式的单元格 Demo4.java package com.wishwzp.poi; import java.io.FileOutputStream; import java.util ...

  5. string[] 和 arraylist互转及问题解决

    1,String 数组转成 list<String> String[] s={"1","2","3","5" ...

  6. DataBase 总结开篇

    系列说明 本系列将总结(SQL)数据库技术在日常开发中引用,读者群体假设为三类:没接触过SQL的入门程序员.有过一两年经验的程序员.三年以上接触过性能调优的程序员.按照这个分类本系列大体分为三篇 第一 ...

  7. 常用的 Internet Browser adds-on/浏览器插件

    主要应用在Firefox, 或 Google Chrome 一.AdBlockPlus 广告屏蔽软件 二.GreaseMonkey 多样化网页 三.Dictionary.com 弹出单词的解释,来自 ...

  8. Markdown編輯器

    MarkDown编辑器 一.什么是Markdown编辑器 二.怎么使用Markdown编辑器 1.标题/Head 2.超链接/Link/Reference ②自動的郵件連結也很類似,只是Markdow ...

  9. [leetcode] 406. Queue Reconstruction by Height

    https://leetcode.com/contest/6/problems/queue-reconstruction-by-height/ 分析:每个表示成(a,b)的形式,其实找第一个,就是b为 ...

  10. NSDate与 NSString 、long long类型的相互转化

    我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3560280.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...