HDU1004 Let the Balloon Rise(map的简单用法)
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
5
green
red
blue
red
red
3
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的简单用法)的更多相关文章
- 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 ...
- Let the Balloon Rise(map)
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- [HDU1004] Let the balloon rise - 让气球升起来
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- Let the Balloon Rise <map>的应用
Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the ...
- HDU 1004 Let the Balloon Rise(map应用)
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- Let the Balloon Rise map一个数组
Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the ...
- HDU1004——Let the Balloon Rise
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- hdu1004 Let the Balloon Rise
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- hdoj-1004-Let the Balloon Rise(map排序)
map按照value排序 #include <iostream> #include <algorithm> #include <cstring> #include ...
随机推荐
- 新浪微博登录界面上下拉伸图片--第三方开源--PullToZoomListViewEx(二)
这是PullZoomView在ScrollView实现,Android PullZoomView在ScrollView的实现是:PullToZoomScrollViewEx 下载地址:https:// ...
- MongoDB探索之路(一)——入门
1.MongoDB和传统关系型数据库的比较 2.面向文档的 NoSQL 数据库主要解决的问题不是高性能的并发读写,而是保证海量数据存储的同时,具有良好的查询性能. 3.MongoDB可以作为日志分 ...
- 开始认真学计算机网络----computer network学习笔记(一)
什么是计算机网络,就是连一堆计算机,计算机不单单指pc,还包括打印机啦,手机啦巴拉巴拉一堆 为什么要连,share data共享数据 数据? 文档,图片,视频,巴拉巴拉 网络有什么类型? LAN--- ...
- ado.net的5个主要对象
connection 连接对象 command 命令对象,指示要执行的命令和存储过程! datareader是一个向前的只读的数据流. dataadapter是功能强大的适陪器,支持增删改查的功能 d ...
- rails 学习笔记
bundle package #保存gem到 vendor/cache bundle install –local 从cache从安装 升级rails bundle config –delete ...
- ubuntu 14.04 下安装jdk8及 smartgithg
公司使用git作为源码管理,又需要在ubuntu下工作,然后,自己就找了找,目前ubuntu下的git gui客户端,感觉 smartgit算是其中比较好用的一个,下边是具体安装步骤 说明,smart ...
- L2-015. 互评成绩
学生互评作业的简单规则是这样定的:每个人的作业会被k个同学评审,得到k个成绩.系统需要去掉一个最高分和一个最低分,将剩下的分数取平均,就得到这个学生的最后成绩.本题就要求你编写这个互评系统的算分模块. ...
- ASP.NET2.0中对TextBox的Enable和ReadOnly属性的限制
在以前的ASP.NET 1.x版本中,设置为ReadOnly的TextBox控件在客户端更改了值后,在服务器端仍然可以得到修改后的值,但在ASP.NET 2.0中,这种做法已经限制.这是为了提高应用程 ...
- wpa_supplicant测试
Android系统中对于WIFI的设置集成到了“设置”中,其实跟手动设置差不多.这里介绍下如何手动连接WIFI,以方便以后调试WIFI. 第一步要做的就是要加载WIFI模块驱动了.当然如果你的WIFI ...
- iOS学习之Object-C语言集合
一.数组类 1.C语言数组的特点:数组是一个有序的集合,用来存储相同数据类型的元素,通过下标访问数组中的元素,下标从0开始. 2.OC中的数组只能存储对象类型(必须是NSObjec ...