Pagini recente » Cod sursa (job #2941163) | Cod sursa (job #2600083) | Cod sursa (job #1413663) | Cod sursa (job #1109592) | Cod sursa (job #2084867)
#include <iostream>
#include <vector>
#include <fstream>
#include <map>
using namespace std;
fstream f1;
int main()
{
int n,i,value;
map <long int,long int> element;
f1.open("elmaj.in",ios::in);
f1>>n;
for(i=0;i<n;i++)
{
f1>>value;
element[value]++;
}
f1.close();
f1.open("elmaj.out",ios::out);
value=0;
for(map <long int, long int>::iterator it=element.begin();it!=element.end();it++)
{
if(element[it->first]>=n/2+1)
{
f1<<it->first<<" "<<element[it->first];
value=1;
}
}
if(value==0) f1<<"-1";
f1.close();
return 0;
}