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. HDU 6012 Lotus and Horticulture(离散化)

    题目代号:HDU 6012 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6012 Lotus and Horticulture Time Limit: ...

  2. WebStorm 在 Mac 版本的基本设置,包括 ES6、Node.js、字体大小等

    WebStorm 在 Mac 和 win 的设置有区别,便于以后用到快速查找,记之. 要设置先点击 WebStorm 字样如下图: 后点击 Preferences 字样如下图: 设置 es6 语法, ...

  3. php 配置优化

    调整php内存限制 vim /usr/local/php/php.ini memory_limit = 1024M 内存优化 /usr/local/php/etc/php-fpm.conf https ...

  4. HDU1026--Ignatius and the Princess I(BFS记录路径)

    Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has ...

  5. Oracle数据库表空间创建、添加用户并授权

    --创建test表空间CREATE TABLESPACE test_data LOGGING DATAFILE '/u01/app/oracle/oradata/test/test_data.dbf' ...

  6. sqli-lab(16)

    现实证明 英语好才能学渗透 基于bool类型的时间盲注 双引号 0X01爱之初体验 说实话我还没有找到 盲注的时候怎么判断闭合的方法 so 这里我直接看源码 这里的语句应该是 (“”)这种的闭合形式 ...

  7. 基于thinkphp开发的项目部署到由宝塔面板创建的LNMP服务器上解决路径出错问题

    一. 环境与版本: 主机:amazon aws EC2主机 系统:Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-1039-aws x86_64) 面板:宝塔免费版 6.9. ...

  8. Centos 建一个指定大小的文件夹

    1.使用ramdisklinux可以把一部分内存mount为分区使用,通常为称为ramdisk,分为ramdisk, ramfs, tmpfs.可以一条命令实现我们的需求:mount none tes ...

  9. gdb调试知识

    之前一直不怎么用gdb,现在要用做一下记录 用gdb启动程序 gdb ./demo intel风格反汇编main函数,一共两行第一行设置汇编风格,第二行才是反汇编main函数 set disassem ...

  10. 【零售App】—— react/ant design mobile项目爬坑

    一.H5制作 - 图片文本的动画效果 bug:打开一个模板,添加图片,添加动画效果,若先选定动画效果,再调节动画时间和延迟时间,则动画和延迟时间没有改变:若先调节动画时间和延迟时间在选定动画效果,则动 ...