Pagini recente » Cod sursa (job #666567) | Cod sursa (job #2054362) | Cod sursa (job #2460738) | Cod sursa (job #831638) | Cod sursa (job #1689693)
#include <fstream>
#include <map>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int N,x;
map<int,int> M;
int main()
{
ios_base::sync_with_stdio(0);
fin.tie(0);
fin>>N;
for(int i=0; i<N; ++i)
{
fin>>x;
M[x]++;
}
for(map<int,int> :: iterator it=M.begin(); it!=M.end(); it++){
if(it->second>=N/2+1){ fout<<it->first<<" "<< it->second; x=0;}
else if(it->second < (N/2+1) && x!=0) x=-1;
}
if(x==-1) fout<<x;
return 0;
}