Pagini recente » Cod sursa (job #795114) | Cod sursa (job #799711) | Cod sursa (job #642316) | Cod sursa (job #2745798) | Cod sursa (job #2084826)
#include <iostream>
#include <map>
#include <fstream>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int main(){
map<long int, long int> vec;
long int n, element, max = 0, key;
fin >> n;
for(long int i = 0; i < n; i++){
fin >> element;
vec[element]++;
}
for(map<long int, long int>::iterator it = vec.begin(); it != vec.end(); it++){
if(max < it->second){
max = it->second;
key = it->first;
}
}
if(max >= n / 2 + 1)
fout << key << " " << vec[key];
else
fout << "-1";
return 0;
}