Pagini recente » Cod sursa (job #1481858) | Cod sursa (job #1414860) | Cod sursa (job #1962494) | Cod sursa (job #2088477) | Cod sursa (job #2964179)
#include <bits/stdc++.h>
using namespace std;
signed main() {
#ifdef ONPC
freopen("input.txt", "r", stdin);
#endif // ONPC
#ifndef ONPC
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
freopen ("elmaj.in", "r", stdin);
freopen ("elmaj.out", "w", stdout);
#endif // ONPC
int n;
cin >> n;
vector<int> a(n);
int biruitor = -1, voturi = 0;
for (auto &x : a) {
cin >> x;
if (!voturi) {
biruitor = x;
voturi = 1;
} else {
if (x == biruitor) {
voturi++;
} else {
voturi--;
}
}
}
voturi = 0;
for (auto &x : a) {
voturi += (x == biruitor);
}
if (voturi > n / 2) {
cout << biruitor << " " << voturi << "\n";
} else {
cout << "-1\n";
}
return 0;
}
/**
**/