HDU 1004 Let the Balloon Rise
来源:互联网 发布:澳门网络彩票 编辑:程序博客网 时间:2024/06/06 22:11
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 105585 Accepted Submission(s): 40844
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
#include <iostream>#include <map>#include <string>using namespace std;int main(){ map<string, int>Ballon; string color, MaxColor; int n, max; while (cin >> n&&n) { Ballon.clear(); while (n--) { cin >> color; Ballon[color]++; } map<string, int>::iterator it; max = 0; for (it = Ballon.begin(); it != Ballon.end(); it++) { if (it->second > max) { max = it->second; MaxColor = it->first; } } cout << MaxColor << endl; } return 0;}
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU--1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- Hdu 1004 - Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU--1004--Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise STL
- ios developer tiny share-20160713
- ubuntu 安装nodejs 4.X版本以上
- CSUOJ 1284 Cutting Cake(递推)
- html select
- java图片裁切工具类
- HDU 1004 Let the Balloon Rise
- Gem: whenever定时执行任务(rake脚本的编写)
- leetcode 344 Reverse String
- POJ 2417 Discrete Logging(BSGS算法,gcd(a,p)=1)
- python打印列表中指定元素的所有下标(5种方法)
- android的帧动画和补间动画总结
- CDH中impala读取不到hive创建的表
- ds1302写时间
- Codeforces Round#321 Kefa and Dishes(状压DP)