Pagini recente » Cod sursa (job #3168255) | Cod sursa (job #3219862) | Cod sursa (job #3208428) | Cod sursa (job #2383860) | Cod sursa (job #2666919)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
unordered_map<int, int> myMap;
int main() {
int N;
fin >> N;
for (int x, i = 0; i < N; ++i) {
fin >> x;
if (myMap.find(x) == myMap.end()) {
myMap[x] = 1;
} else {
myMap[x] += 1;
}
}
for (auto &x: myMap) {
if (x.second >= (N / 2 + 1)) {
fout << x.first << ' ' << x.second << '\n';
return 0;
}
}
fout << -1 << '\n';
return 0;
}