HDU 1004
来源:互联网 发布:淘小白自动发货软件 编辑:程序博客网 时间:2024/06/05 22:49
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 89468 Accepted Submission(s): 33892
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.
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.
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
5greenredblueredred3pinkorangepink0
#include<cstdio>#include<iostream>#include<cstring>#include<string>#include<algorithm>#include<map>using namespace std;map<string,int>myMap;int main(){ int n; string str[1010]; while(~scanf("%d",&n)&&n) { myMap.clear(); getchar(); for(int i = 0; i < n; i++) { cin >> str[i]; myMap[str[i]]++; } int max = 0, mark = 0; for(int i = 0; i < n; i++) { if(max < myMap[str[i]]) { max = myMap[str[i]]; mark = i; } } cout << str[mark] <<endl; } return 0;}
0 0
- HDU 1004
- Hdu 1004
- HDU 1004
- hdu 1004
- hdu 1004
- hdu 1004
- HDU-1004
- hdu 1004
- HDU 1004
- HDU 1004
- hdu 1004
- HDU 1004
- hdu 1004
- HDU 1004
- hdu--1004
- HDU 1004
- HDU 1004
- hdu-1004
- WEB开发三层架构及MVC设计模式概述
- cell去掉底部多余的表格线
- 【JAVA】JAVA应用程序以及JVM性能调优实例
- 【机房收费系统】——报表(二)
- JTextArea DEMO
- HDU 1004
- 开源 java CMS - FreeCMS2.3会员我的收藏
- 周鸿祎的一段话,让我受益匪浅
- 线程安全C/C++ http://blog.csdn.net/huangxy10/article/details/8068653
- POJ 3104 Drying Clothes
- 四元数与欧拉角(yaw roll pitch)转换公式与推导,以及它们unity中的不同
- hd1272 小希的迷宫
- iOS 设计模式之中介者模式
- 同步非阻塞I/O——NIO(一)基于文件操作