Pagini recente » Cod sursa (job #415661) | Cod sursa (job #671069) | Cod sursa (job #2562318) | Cod sursa (job #2207123) | Cod sursa (job #2148807)
#include <iostream>
#include <map>
#include <fstream>
using namespace std;
ifstream in("elmaj.in");
ofstream out("elmaj.out");
map <int,long int> schema;
int main()
{
int n;
in>>n;
for(int i=1;i<=n;i++)
{
int x;
long int y;
in>>x;
schema[x]++;
}
int max_value=0;
int max_count=0;
map <int,long int> ::iterator itr;
for(itr = schema.begin(); itr!=schema.end();itr++)
{
int itr_value=itr->first;
long int itr_count=itr->second;
if(itr_count>max_value)
{
max_value=itr_value;
max_count=itr_count;
}
}
if(max_count>n/2)
out<<max_value<<" "<<max_count;
else
out<<-1;
}