Pagini recente » Cod sursa (job #2158434) | Cod sursa (job #63075) | Cod sursa (job #3145004) | Cod sursa (job #1664088) | Cod sursa (job #639313)
Cod sursa(job #639313)
#include<fstream>
#include<map>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
map<int,int> hh ;
int n;
void Solve()
{
fin>>n;
int x, i=1;
for(;i<=n;++i)
{
fin>>x;
if( hh.find(x) == hh.end() )
{
hh.insert(make_pair(x,1));
}
else
++hh[x];
}
}
void Afisare()
{
map<int,int>::iterator it;
n= n/2 + 1;
for ( it = hh.begin() ; it != hh.end(); ++it )
if((*it).second >= n )
{
fout<<(*it).first<<" "<< (*it).second << endl;
return ;
}
fout<<-1<<endl;
}
int main()
{
Solve();
Afisare();
return 0;
}