Pagini recente » Cod sursa (job #2069318) | Cod sursa (job #1242106) | Cod sursa (job #3184047) | Cod sursa (job #2717870) | Cod sursa (job #639302)
Cod sursa(job #639302)
#include<fstream>
#include<bitset>
#include<map>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
map<long,int> hh ;
int n;
int nr;
void Solve()
{
fin>>n;
long x;
for(int i=1;i<=n;++i)
{
fin>>x;
if( hh.find(x) == hh.end() )
{
hh.insert(make_pair(x,1));
}
else
++hh[x];
}
}
int Afisare()
{
map<long,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 1;
}
return 0;
}
int main()
{
Solve();
if ( Afisare() == 0 )
fout<<"-1\n";
fout.close();
fin.close();
return 0;
}