Pagini recente » Cod sursa (job #2179508) | Cod sursa (job #1672035) | Cod sursa (job #1054213) | Cod sursa (job #347972) | Cod sursa (job #639323)
Cod sursa(job #639323)
#include<fstream>
#include<cstdio>
#include<map>
using namespace std;
ifstream fin("elmaj.in");
map<int,int> hh ;
int n;
int i;
inline void Solve()
{
fin>>n;
int x;
for( i=0;i<n;++i)
{
fin>>x;
if( hh.find(x) == hh.end() )
{
hh.insert(make_pair(x,1));
}
else
++hh[x];
}
}
inline 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 )
{
printf("%d %d\n",it->first, it->second);
return ;
}
printf("-1\n");
}
int main()
{
Solve();
Afisare();
fin.close();
return 0;
}