Pagini recente » Cod sursa (job #3132533) | Cod sursa (job #401053) | Cod sursa (job #1953761) | Cod sursa (job #406373) | Cod sursa (job #1689687)
#include <fstream>
#include <map>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
long long N,x,k;
map<long long,long long> M;
int main()
{
fin>>N;
for(int i=0; i<N; ++i)
{
fin>>x;
M[x]++;
if(M[x]>=N/2+1)
{
k=-1;
fout<<x<<" "<<M[x];
break;
}
}
if(k!=-1) fout<<"-1";
/*for(map<int,int> :: iterator it=M.begin(); it!=M.end(); it++){
if(it->second>=N/2+1){ fout<<it->first<<" "<< it->second; break;}
else if(it==--M.end() && it->second<(N/2+1)) fout<<"-1";
}*/
return 0;
}