Pagini recente » Cod sursa (job #2027783) | Cod sursa (job #293193) | Cod sursa (job #2737286) | Cod sursa (job #581322) | Cod sursa (job #1052462)
#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;
int main()
{
long n, i, x;
bool gasit = false;
//int v[100001];
unordered_map <int, int> element;
unordered_map <int, int>::iterator it;
ifstream f("elmaj.in");
ofstream g("elmaj.out");
f >> n;
for (i=1; i<=n; ++i)
{
f >> x;
element[x]++;
}
int constanta = n/2+1;
for ( it=element.begin(); it!=element.end(); ++it)
if ((it->second >= constanta) && (gasit == false))
{
g << it->first <<" " << it->second;
gasit = true;
}
if (gasit == false)
g << "-1";
return 0;
}