Pagini recente » Cod sursa (job #2313704) | Cod sursa (job #1395733) | Cod sursa (job #2211936) | Cod sursa (job #2464899) | Cod sursa (job #2666916)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
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;
}