Pagini recente » Cod sursa (job #2204616) | Cod sursa (job #768355) | Cod sursa (job #1342797) | Cod sursa (job #3297609) | Cod sursa (job #1171673)
#include <fstream>
#include <map>
using namespace std;
int N;
map<int, int> mappings;
map<int,int>::iterator it;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
void init(){
for(int i = 0; i < 2 * 1000000000 + 1; i++){
mappings[i] = 0;
}
}
int main(){
fin >> N;
int x, count = -1, who = -1;
init();
for(int i = 0; i < N; i++){
fin >> x;
mappings[x] += 1;
}
for (map<int,int>::iterator it=mappings.begin(); it!=mappings.end(); ++it){
if(it->second > count){
count = it->second;
who = it->first;
}
}
if(count >= N/2 + 1)
fout << who << " " << count << "\n";
else
fout << "-1\n";
return 0;
}