Pagini recente » Cod sursa (job #1633189) | Cod sursa (job #1264535) | Cod sursa (job #444236) | Diferente pentru problema/omogene intre reviziile 4 si 3 | Cod sursa (job #3226766)
#include <iostream>
#include <fstream>
#include <map>
using namespace std;
ifstream f("elmaj.in");
ofstream g("elmaj.out");
map<int, int> M;
int i, n, x;
int main()
{
f >> n;
for (i = 1; i <= n; i++)
{
f >> x;
M[x]++;
}
for (auto e : M)
if (e.second >= (n+1)/2)
{
g << e.first << " " << e.second << "\n";
return 0;
}
g << "-1\n";
return 0;
}