Pagini recente » Cod sursa (job #943828) | Cod sursa (job #213192) | Cod sursa (job #2074602) | Cod sursa (job #419835) | Cod sursa (job #1051597)
#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream f("elmaj.in");
ofstream g("elmaj.out");
unordered_map<int, int> h;
unordered_map<int, int>::iterator it;
int n, a;
int main()
{
f>>n;
for(int i=0; i<n; ++i){
f>>a;
h[a]++;
}
for(it=h.begin(); it!=h.end(); ++it){
if(it->second>=n/2+1){
g<<it->first<<' '<<it->second<<'\n';
return 0;
}
}
g<<-1;
return 0;
}