Pagini recente » Cod sursa (job #557153) | Cod sursa (job #2759849) | Cod sursa (job #2042077) | Cod sursa (job #2084392) | Cod sursa (job #1477534)
// Galatan Tudor - Liceul Teoretic "Ion Luca"
// Vatra Dornei, 26.08.2015
#include <fstream>
#define R 1000001
using namespace std;
ifstream f("elmaj.in");
ofstream g("elmaj.out");
int nr_ap[R];
int n, i, x, el_maj;
int main ()
{
f >> n;
for (i=0; i<n; i++)
{
f >> x;
nr_ap[x]++;
if (nr_ap[x] > nr_ap[el_maj])
el_maj = x;
}
if (nr_ap[el_maj] >= n/2+1)
g << el_maj << " " << nr_ap[el_maj];
else
g << "-1";
return 0;
}