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.
A test case with N = 0 terminates the input and this test case is not to be processed.
5 green red blue red red 3 pink orange pink 0
red pink
#include<iostream>
#include<cstdio>#include<string>
#include<vector>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)&&n)
{
string s;
vector<int>times;
vector<string>color;
for(int i=0;i<n;i++)
{
cin>>s;
color.push_back(s);
}
for(int j=0;j<color.size();j++)
times.push_back(1);
for(int i=0;i<color.size();i++)
{
for(int j=i+1;j<color.size();j++)
{
if(color[i]==color[j])
{
times[j]++;
times[i]++;
}
}
}
int max=0;
string Smost;
for(int i=0;i<times.size();i++)
{
if(times[i]>max)
{
max=times[i];
Smost=color[i];
}
}
cout<<Smost<<endl;
}
return 0;
}