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 ...
随机推荐
- php的swoole扩展中onclose和onconnect接口不被调用的问题
在用swoole扩展写在线聊天例子的时候遇到一个问题,查了不少资料,现在记录于此. 通过看swoole_server的接口文档,回调注册接口on中倒是有明确的注释: * swoole_server-& ...
- Jquery note
the purpose: write less. do more 写得少,做更多 jquery 基本选择器, $("p ,div ")匹配所有的P元素和DIV元素 , $(&q ...
- Mayan游戏 (codevs 1136)题解
[问题描述] Mayan puzzle是最近流行起来的一个游戏.游戏界面是一个7行5列的棋盘,上面堆放着一些方块,方块不能悬空堆放,即方块必须放在最下面一行,或者放在其他方块之上.游戏通关是指在规定的 ...
- delphi android 中 Toast 的实现(老外写的UNIT)
unit Android.JNI.Toast; // Java bridge class imported by hand by Brian Long (http://blong.com)interf ...
- SHOW SLAVE STATUS几个常见参数
--显示当前读取的Master节点二进制日志文件和文件位置,对应线程I/O thread Master_Log_File: mysql-bin.000011 Read_Master_Log_Pos: ...
- 开始认真学计算机网络----computer network学习笔记(一)
什么是计算机网络,就是连一堆计算机,计算机不单单指pc,还包括打印机啦,手机啦巴拉巴拉一堆 为什么要连,share data共享数据 数据? 文档,图片,视频,巴拉巴拉 网络有什么类型? LAN--- ...
- 《高性能javascript》读书笔记
1.每个<script>加载时都会阻塞其他文件(图片.音乐等)的同时加载,同时浏览器会在js代码执行时停止渲染Dom.所以为了减少界面加载的卡顿和空白发生,应尽力将js代码或者文件放在&l ...
- Java jdk环境变量配置
首先安装jdk,现在已经是jdk 8了,也不知道能不能好好用了...
- 转载: android 学习架构
http://www.cnblogs.com/forlina/archive/2011/06/29/2093332.html 引言 通过前面两篇: Android 开发之旅:环境搭建及HelloWor ...
- 菜鸟学习Hibernate——一对多关系映射
Hibernate中的关系映射,最常见的关系映射之一就是一对多关系映射例如学生与班级的关系,一个班级对应多个学生.如图: Hibernate中如何来映射这两个的关系呢? 下面就为大家讲解一下: 1.创 ...