Let the Balloon Rise

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

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
分析:STL大法好啊,本题要求最大的气球数,可以用到STL标准库中的map<string,int>来保存,当map的first插入一个string的时候,map的second++,就可以统计出具体的string的个数了,然后遍历找到最大值就可以了!
下面给出AC代码:
 #include <bits/stdc++.h>
using namespace std;
int main()
{
map<string,int>ballon;
int n;
string str;
while(cin>>n&&n)
{
ballon.clear();
while(n--)
{
cin>>str;
ballon[str]++;
}
int maxn=;
string maxcolor;
map<string,int>::iterator it;
for(it=ballon.begin();it!=ballon.end();it++)
{
if(it->second>maxn)
{
maxn=(*it).second;
maxcolor=(*it).first;
}
}
cout<<maxcolor<<endl;
}
return ;
}

HDU 1004 Let the Balloon Rise【STL<map>】的更多相关文章

  1. hdu 1004 Let the Balloon Rise strcmp、map、trie树

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

  2. HDU 1004 Let the Balloon Rise(STL初体验之map)

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

  3. hdu 1004 Let the Balloon Rise(字典树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  4. HDU 1004 Let the Balloon Rise(map的使用)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  5. hdu 1004 Let the Balloon Rise

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

  6. 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 ...

  7. hdu 1004 Let the Balloon Rise 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 用STL 中的 Map 写的 #include <iostream> #includ ...

  8. HDU 1004 - Let the Balloon Rise(map 用法样例)

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

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

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

随机推荐

  1. 在 ReactNative 的 App 中,集成 Bugly 你会遇到的一些坑

    一.前言 最近开新项目,准备尝试一下 ReactNative,所以前期做了一些调研工作,ReactNative 的优点非常的明显,可以做到跨平台,除了少部分 UI 效果可能需要对不同的平台进行单独适配 ...

  2. iOS tableview和 Collection复用机制

    TableView的重用机制,为了做到显示和数据分离, tableView的实现并且不是为每个数据项创建一个tableCell.而是只创建屏幕可显示最大个数的cell,然后重复使用这些cell,对ce ...

  3. Hosts文件实际应用 配置内部服务器提高访问效率和速度

    一 hosts文件的作用和介绍 https://jingyan.baidu.com/article/335530da45485e19cb41c3d6.html https://www.cnblogs. ...

  4. Jenkins 关闭和重启实现方式.

    1.关闭Jenkins 只需要在访问jenkins服务器的网址url地址后加上exit.例如我jenkins的地址http://localhost:8080/,那么我只需要在浏览器地址栏上敲下http ...

  5. 后缀数组之hihocoder 重复旋律1-4

    蒟蒻知道今天才会打后缀数组,而且还是nlogn^2的...但基本上还是跑得过的: 重复旋律1: 二分答案,把height划分集合,height<mid就重新划分,这样保证了每个集合中的LCP&g ...

  6. Ubuntu Nginx 开机自启动

    #! /bin/sh # chkconfig: 2345 55 25 # Description: Startup script for nginx webserver on Debian. Plac ...

  7. 删除SVN版本信息的两种方式

    一.在linux下删除SVN版本信息 删除这些目录是很简单的,命令如下 find . -type d -name ".svn"|xargs rm -rf 或者 find . -ty ...

  8. bug运输[辽宁2014年省队互测一]

    奇奇怪怪的题目,不知道他要我们干什么. 我们观察一波局势,发现答案最大不过5.因为如果答案是6或以上的话,我们就至少要2^(5*5)个5*5的方格. 仔细计算一波时间复杂度,再信仰一波,坚信暴力压正解 ...

  9. python中顺序查找分析和实现

    顺序查找算法是一种很基本的查找算法,该算法的复杂度一般是最大是O(n),假如加上顺序查找,算法的复杂度 还要降一倍,为O(n/2). Python的代码实现如下所示: def sequential_s ...

  10. web打印总结

    一.打印样式 区别显示和打印的样式 使用media="print"控制打印时的样式,如下: 打印时不显示打印按钮,设置页面宽度 <style media="prin ...