Pagini recente » Cod sursa (job #481008) | Cod sursa (job #2296145) | Cod sursa (job #384983) | Cod sursa (job #2751369) | Cod sursa (job #1672785)
#include <fstream>
#include<iostream>
#include<map>
using namespace std;
ifstream f("elmaj.in");
ofstream g("elmaj.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 (v.find(x)!= 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];
f.close();g.close();
return 0;
}