博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU-1004 Let the Balloon Rise STL map
阅读量:5948 次
发布时间:2019-06-19

本文共 1590 字,大约阅读时间需要 5 分钟。

Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 30799    Accepted Submission(s): 10110

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
 
  直接使用map来映射,方便至极。
#include 
#include
#include
using namespace std;int main( ){ int N; while( cin>> N, N ) { string temp; map< string, int > mp; map< string, int >:: iterator it; for( int i= 1; i<= N; ++i ) { cin>> temp; mp[temp]++; } int max= -1; for( it= mp.begin(); it!= mp.end(); ++it ) { if( max< it->second ) { max= it->second; temp= it->first; } } cout<< temp<< endl; }}

转载于:https://www.cnblogs.com/Lyush/archive/2011/07/31/2122762.html

你可能感兴趣的文章
Maven构建web项目在Eclipse中部署的几种方法
查看>>
[多文件上传三]利用UrlEncodedFormEntity表单实现
查看>>
左边邮件类型
查看>>
怎么能确保分类中的方法不和原始类的方法冲突?
查看>>
Python-pip, RubyGems, node-npm使用国内镜像加速下载
查看>>
C 语言静态变量的作用域和生存周期(ZZ)
查看>>
C++是可以在类里面定义和类名相同的变量的
查看>>
Linux socket 编程中 write 函数使用的注意事项
查看>>
eclipse开发环境
查看>>
如何计算硬盘、RAID组与Ceph的IOPS!!!
查看>>
18至今,学习Linux让我快速成长的三件事
查看>>
keepalived+nginx搭建高可用几个注意点
查看>>
pyinstaller 打包后运行错误
查看>>
一步一步学Ruby(十六):符号
查看>>
Spring Session + redis实现session共享
查看>>
阿里云的maven仓库
查看>>
hash table碰撞处理
查看>>
Oracle事务
查看>>
Spark2.0操作ES
查看>>
代码创建UISearchDisplayCountroller
查看>>