Let the Balloon Rise
来源:互联网 发布:吴亦凡 扒皮 知乎 编辑:程序博客网 时间:2024/06/07 00:10
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 81218 Accepted Submission(s): 30615
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
Sample Output
redpink
Author
WU, Jiazhi
#include<iostream>#include<algorithm>#include<string>#include<string.h>using namespace std;int main(){ int N,i,login; string s[1000]; string f[1000]; int ji[1000]; while(scanf("%d",&N),N) { int max='\0'; int j=0;int k=0; for(i=0;i<N;i++) { cin>>s[i]; } sort(s,s+N); int count=1; // AAABBB for(i=0;i<N;i++) { while(i<N-1 && (s[i]==s[i+1])) { count++; i++; } f[j++]=s[i]; ji[k++]=count; count=1; } for(i=0;i<k;i++) { if(ji[i]>max) { max=ji[i]; login=i; } } cout<<f[login]<<endl; } return 0;}
0 0
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the balloon rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- 乱弹java并发(三)-- CopyOnWriteArrayList和CopyOnWriteArraySet
- 初探NO.3—从头到尾聊聊贝叶斯的分类方法
- UVA 10487 Closest Sums(二分)
- 最大连续子序和 (加强版?)
- java.sql.SQLException:Invalid value for getInt()-'zhangsan'
- Let the Balloon Rise
- PHP HttpClient模拟登陆
- 新站必须经过的几个百度时期
- 在安卓service中启动相机
- (四十一)数据持久化的NSCoding实现 -实现普通对象的存取
- 面向对象-基础
- 【Android如何禁止横竖屏切换】
- 提交订单后跳转回购物车的问题
- java.sql.SQLException:Can not issue data manipulation statements with executeQuery()