Pagini recente » Cod sursa (job #1562144) | Cod sursa (job #1169669) | Cod sursa (job #1510681) | Cod sursa (job #2507473) | Cod sursa (job #2615195)
#include <bits/stdc++.h>
#define DAU ios_base::sync_with_stdio(false); fin.tie(0); fout.tie(0);
#define PLEC fin.close(); fout.close(); return 0;
using namespace std;
const string problem("elmaj");
ifstream fin(problem + ".in");
ofstream fout(problem + ".out");
using PII = pair<int, int>;
unordered_map<int, int> freq;
int n, x, res(-1);
int main() {
DAU
fin >> n;
for (int i = 1; i <= n; ++i)
fin >> x, ++freq[x];
for (const PII& P : freq)
if (P.second > n / 2)
res = P.first;
fout << res << ' ';
if (res != -1)
fout << freq[res];
PLEC
}