Pagini recente » Cod sursa (job #1155107) | Cod sursa (job #2225750) | Cod sursa (job #1641575) | Cod sursa (job #459413) | Cod sursa (job #2955300)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("elmaj.in");
ofstream cout("elmaj.out");
long long x, n, freq[100001], maxim, nmax, nr;
int main()
{
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> x;
if(x > nmax)
nmax = x;
freq[x]++;
}
for(int i = 0; i <= nmax; i++)
{
if(freq[i] > maxim)
maxim = i, nr = freq[i];
}
if(nr >= n / 2 + 1)
cout << maxim << " " << nr;
else
cout << -1;
return 0;
}