Pagini recente » Cod sursa (job #1365560) | Cod sursa (job #690583) | Cod sursa (job #426673) | Cod sursa (job #1789619) | Cod sursa (job #2554984)
#include <iostream>
#include <fstream>
#include <map>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int n;
map<int, int> M;
int main()
{
fin >> n;
for (int i = 1; i <= n; ++i)
{
int x;
fin >> x;
++M[x];
}
bool gasit = false;
for (auto x : M)
{
if (x.second >= n / 2 + 1)
{
gasit = true;
fout << x.first << " " << x.second;
}
}
if (!gasit)
fout << -1;
return 0;
}