Pagini recente » Cod sursa (job #2841357) | Cod sursa (job #3000769) | Cod sursa (job #2589481) | Cod sursa (job #107767) | Cod sursa (job #1689679)
#include <fstream>
#include <map>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int N,x;
map<int,int> M;
int main()
{
fin>>N;
for(int i=0; i<N; ++i)
{
fin>>x;
M[x]++;
if(M[x]>=N/2+1){
fout<<x<<" "<<M[x];
break;
}
else
x=-1;
}
if(x==-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;
}