Pagini recente » Cod sursa (job #1978088) | Cod sursa (job #463826) | Cod sursa (job #2871441) | Cod sursa (job #1466148) | Cod sursa (job #1656335)
#include <iostream>
#include <fstream>
#include <map>
#include <vector>
using namespace std;
map<int,int>m;
vector<int>a;
int n;
int main()
{
ifstream fin("elmaj.in");
fin>>n;
for(int i=0;i<n;i++)
{
int element;
fin>>element;
m[element]++;
}
map<int,int>::iterator it=m.begin();
map<int,int>::iterator stop=m.end();
ofstream fout("elmaj.out");
for(;it!=stop;it++)
{
if(it->second>=(n/2+1))
{
fout<<it->first<<' '<<it->second<<'\n';
return 0;
}
}
fout<<-1<<'\n';
return 0;
}