Pagini recente » Cod sursa (job #154789) | Cod sursa (job #157508) | Cod sursa (job #2071520) | Cod sursa (job #2670525) | Cod sursa (job #1672783)
#include <fstream>
#include<iostream>
#include<map>
using namespace std;
ifstream f("majoritar.in");
ofstream g("majoritar.out");
map<long,long> v;
map<long,long>::iterator it;
int main()
{long N,max=0,x,ind;
f>>N;
for(long i=1;i<=N;i++)
{f>>x;
it=v.find(x);
if (it!= v.end()) v[x]++;
else v[x]=1;
if(v[x]>max) {max=v[x];ind=x;}}
if(v[ind]<N/2) g<<-1;
else g<<ind<<" "<<v[ind];
return 0;
}