Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) 
Total Submission(s): 106421 Accepted Submission(s): 41214

Problem Description 
Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result. 
This year, they decide to leave this lovely job to you.

Input 
Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters. 
A test case with N = 0 terminates the input and this test case is not to be processed.

Output 
For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case.

Sample Input 

green 
red 
blue 
red 
red 

pink 
orange 
pink 
0

Sample Output 
red 
pink

Author 
WU, Jiazhi

Source 
ZJCPC2004

Recommend 
JGShining
关于map的一些用法: 
http://www.cnblogs.com/BeyondAnyTime/archive/2012/08/24/2654353.html

 #include<bits/stdc++.h>
using namespace std;
int main(){
int t,max;
string s,ms;
map<string,int> p;
while(cin>>t&&t!=){
p.clear();
for(int i=;i<t;i++){
cin>>s;
p[s]++;//
}
max=;
map<string,int>::iterator i;
for(i=p.begin();i!=p.end();i++){
if(max<i->second){
ms=i->first;
max=i->second;
}
}
cout<<ms<<endl;
}
}

HDU1004 Let the Balloon Rise(map的简单用法)的更多相关文章

  1. HDU 1004 Let the Balloon Rise map

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  2. Let the Balloon Rise(map)

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  3. [HDU1004] Let the balloon rise - 让气球升起来

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  4. Let the Balloon Rise <map>的应用

    Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the ...

  5. HDU 1004 Let the Balloon Rise(map应用)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  6. Let the Balloon Rise map一个数组

    Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the ...

  7. HDU1004——Let the Balloon Rise

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  8. hdu1004 Let the Balloon Rise

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  9. hdoj-1004-Let the Balloon Rise(map排序)

    map按照value排序 #include <iostream> #include <algorithm> #include <cstring> #include ...

随机推荐

  1. php的swoole扩展中onclose和onconnect接口不被调用的问题

    在用swoole扩展写在线聊天例子的时候遇到一个问题,查了不少资料,现在记录于此. 通过看swoole_server的接口文档,回调注册接口on中倒是有明确的注释: * swoole_server-& ...

  2. Spark官方文档——本地编写并运行scala程序

    快速开始 本文将介绍如何用scala.java.python编写一个spark单击模式的程序. 首先你只需要在一台机器上成功建造Spark:做法: 进入Spark的根目录,输入命令:$ sbt/sbt ...

  3. ASP.NET MVC5学习笔记之Action参数模型绑定值提供体系

    这一节我们关注模型绑定的值提供体系,先来介绍几个重要的接口 一. IValueProvider,接口定义如下: public interface IValueProvider { bool Conta ...

  4. 基于Memcached的Session共享问题

    把Memcached的key(Guid)写入浏览器的cookie(类比SessionId) 存值: string sessionId = Guid.NewGuid().ToString(); Comm ...

  5. ios 工程图片清理shell

    #!/bin/shecho "随意删除@2x图片可能会引起错误 因为ios工程会更加前缀和分辨率自己找到@2x的图片 所以删除@2x图片时要慎重"read -n1 -p  &quo ...

  6. C#调用sap接口及返回数据到sap

    public class SapClass { /// <summary> /// /// </summary> /// <param name="fphm&q ...

  7. 解决mysql登陆时出现“ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)”

    mariadb同样适用 首先检查mysql状态 linux-6yo1:~ # /etc/init.d/mysql status Checking for service MySQL: unused m ...

  8. linux下更改文件夹所属用户和用户组

    改变所属用户组:chgrp -R users filename -R是为了递归改变文件夹下的文件和文件夹,users是要改为的用户组名称,filename是要改变的文件夹名称 ============ ...

  9. Java Collections Source Code Series 1 --- 简介

    废话开篇 由于项目需要,需要对Java Collections进行系统地了解,所以在此记录下,方便自己,服务他人. Java Collections 简介 Java Collections 框架主要包 ...

  10. golang反射初试

    golang反射来自Go AST(Abstract Syntax Tree). reflect操作更多像traverse AST. t := reflect.TypeOf(obj) 使用TypeOf( ...