Let the Balloon Rise

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

Total Submission(s): 124433    Accepted Submission(s): 49101

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
#include<iostream>
#include<string>
#include<cstdio>
#include<map>

using namespace
std; int main(){
map<string,int>mp;
string color,tmp;
int
n;
while(
scanf("%d",&n)==1 && n){
mp.clear();
for(int
i=1;i<=n;i++){
cin >> color;
mp[color]++;
}

map<string,int>::iterator it;
int
ans = -1;
for(
it=mp.begin();it!=mp.end();it++){
if((*
it).second > ans ){
ans = (*it).second;
color = (*it).first;
}
}

printf("%s\n",color.c_str());
}
}

STL: HDU1004Let the Balloon Rise的更多相关文章

  1. hdu1004Let the Balloon Rise

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

  2. HDU 1004 Let the Balloon Rise【STL<map>】

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

  3. STL-map-A - Let the Balloon Rise

    A - Let the Balloon Rise Contest time again! How excited it is to see balloons floating around. But ...

  4. 杭电1004 Let the Balloon Rise

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

  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. Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏

    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 map

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

  8. HDU1004 Let the Balloon Rise(map的简单用法)

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

  9. HD1004Let the Balloon Rise

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

随机推荐

  1. node.js入门学习(二)MIME模块,request和response对象,demo之不同url请求不同html页面,页面包含图片、样式css等静态资源

    一.构建http服务程序-根据不同请求做出不同响应 // 加载http模块 var http = require("http"); // 创建一个http服务对象 http.cre ...

  2. PWM 定义

    简单的说,比如你有5V电源,要控制一台灯的亮度,有一个传统办法,就是串联一个可调电阻,改变电阻,灯的亮度就会改变.还有一个办法,就是PWM调节.不用串联电阻,而是串联一个开关.假设在1秒内,有0.5秒 ...

  3. Android使用SDKManager下载SDK速度慢 容易丢包和异常的解决办法

    第一步, SDK Manager启动之后,会先解析一些google的xml文件,会在Log里面打印出一些日志信息. 解析完之后,把日志全部拷贝到一个记事本里(这一步是因为日志窗口不支持查找),在里面查 ...

  4. 基本的axios用法

    首先安装axios: 1):npm install 2):npm install vue-axios --save 3):npm install qs.js --save //它的作用是能把json格 ...

  5. NDK下编译JNI

    NDK环境下编译JNI 下载demo.tar.gz然后解压 弄个套路 1.编辑build.sh设置好NDK目录 2.把cpp文件放到code下面 运行sh build.sh即可

  6. 【洛谷T89379 【qbxt】复读警告】

    题目链接 这个题可以应用dp #include<bits/stdc++.h> using namespace std; ; inline int read() { ,b=; char c= ...

  7. nginx请求转发配置

    以下为无ssl证书配置的请求转发 server { listen ; server_name api.****.com; #以下为指定请求域名匹配到某一个端口 #location ~* /union ...

  8. 关于加快INSERT语句执行速度和HINT /*+ append */及/*+ append nologging */的使用

    (非归档模式下)创建表T01: SQL> create table t01 as select * from dba_objects where 1=2; Table created. (非归档 ...

  9. VS调试异常代码 HRESULT:0x80070057 (E_INVALIDARG)解决方法

    我目前在做的一个系统是VS2010写的的B/S架构程序, 主要技术是:C#.SQLSERVER2008.NHibernate,Python,Nhibernate 的*.hbn.xml是映射数据库的表结 ...

  10. Linux_指令杂烩

    目录 目录 指令集合 常用于脚本的指令 查看变量的指令 监控命令 除了root用户的其他用户不能login 重定向 grep 过滤文件内容 vim预设定 系统在启动时要依次运行4个脚本 归档压缩文件互 ...