Pagini recente » Cod sursa (job #55469) | Cod sursa (job #497039) | Cod sursa (job #650755) | Cod sursa (job #2325241) | Cod sursa (job #2084901)
#include <iostream>
#include <fstream>
#include <map>
using namespace std;
ifstream fin;
ofstream fout;
int main()
{
int n,i,value,b=0,max,key;
map <long int,long int> element;
fin.open("elmaj.in");
fin>>n;
max=0;
for(i=0;i<n;i++)
{
fin>>value;
element[value]++;
if(max<element[value])
{
max=element[value];
key=value;
}
}
fin.close();
if(max>=n/2+1)
{
fout.open("elmaj.out");
fout<<key<<" "<<max;
fout.close();
}
else
{
fout.open("elmaj.out");
fout<<"-1";
fout.close();
}
return 0;
}