Pagini recente » Cod sursa (job #1615270) | Cod sursa (job #1398391) | Cod sursa (job #1725500) | Profil krisztian1997 | Cod sursa (job #2075222)
#include <iostream>
#include <fstream>
#include <hash_map>
using namespace std;
using namespace __gnu_cxx;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int main()
{
hash_map<int, int> hashTable;
hash_map<int, int>::iterator it;
int x, n;
fin>>n;
while (fin>>x) {
if (hashTable.count(x)) {
hashTable[x]++;
} else {
hashTable[x] = 1;
}
}
bool gasit = 0;
for (it = hashTable.begin(); it != hashTable.end(); it++) {
int val = it->second;
if (val > n/2) {
fout<<it->first<<' '<<val;
gasit = 1;
break;
}
}
if (gasit == 0) {
fout<<-1;
}
return 0;
}