Pagini recente » Cod sursa (job #164313) | Cod sursa (job #894294) | Cod sursa (job #2784798) | Cod sursa (job #2880919) | Cod sursa (job #3147745)
#include <bits/stdc++.h>
using namespace std;
string out[2]{ "NO", "YES" };
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
const char sp = ' ';
const char nl = '\n';
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
#define all(y) y.begin(), y.end()
int n;
const int sqvalmax = 44722;
int a[sqvalmax + 5]{ 0 }, b[sqvalmax + 5]{ 0 };
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
fin >> n;
fill(a, a + sqvalmax + 1, 0);
fill(b, b + sqvalmax + 1, 0);
for (int i = 1; i <= n; ++i) {
int x;
fin >> x;
a[x / sqvalmax]++;
b[x % sqvalmax]++;
}
int amax = max_element(a, a + sqvalmax + 1) - a;
int bmax = max_element(b, b + sqvalmax + 1) - b;
int res = amax * sqvalmax + bmax;
fin.close(), fin.open("elmaj.in");
fin >> n;
int cnt = 0;
for (int i = 1; i <= n; ++i) {
int x;
fin >> x;
if (x == res) {
cnt++;
}
}
if (cnt > n / 2) {
fout << res << sp << cnt;
}
else {
fout << -1;
}
}