Pagini recente » Cod sursa (job #2731871) | Cod sursa (job #1388869) | Istoria paginii runda/conchita/clasament | Cod sursa (job #2921556) | Cod sursa (job #2955288)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("elmaj.in");
ofstream cout("elmaj.out");
int 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;
}