Pagini recente » Cod sursa (job #3124775) | Cod sursa (job #2352642) | Cod sursa (job #1418937) | Cod sursa (job #330101) | Cod sursa (job #640015)
Cod sursa(job #640015)
#include<fstream>
#include<cstdio>
#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;
for( i=1;i<=n;++i)
{
fin>>x;
if( hh.find(x) == hh.end() )
hh.insert(make_pair(x,1));
else
++hh[x];
}
}
void Afisare()
{
freopen("elmaj.out","w",stdout);
map<int,int>::iterator it;
n= n/2 ;
for ( it = hh.begin() ; it != hh.end(); ++it )
if((*it).second > n )
{
//fout<<(*it).first<<" "<< (*it).second << endl;
printf("%d %d\n",it->first, it->second);
return ;
}
//fout<<-1<<"\n";
printf("-1\n");
}
int main()
{
Solve();
Afisare();
//fout.close();
//fin.close();
return 0;
}