Pagini recente » Clasament valoare-- | Cod sursa (job #1178161) | preONI 2008 - Clasament Runda 3, Clasa a 10-a | Clasament oji-2008-11-12 | Cod sursa (job #2553192)
# include <bits/stdc++.h>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout ("elmaj.out");
int n, x, elmaj, f, s;
int main ()
{
fin >> n;
fin >> x;
elmaj = x;
f = 1;
for ( int i = 1; i < n; ++i)
{
fin >> x;
if ( f == 0)
elmaj = x;
if (elmaj == x)
++f;
else
--f;
}
fin.close();
fout.close();
ifstream fin ("elmaj.in");
ofstream fout ("elmaj.out");
for ( int i = 1; i <= n; ++i)
{
fin >> x;
if(x == elmaj)
++f;
}
if(f > n/2)
fout << elmaj << " " << f;
else
fout << "-1";
return 0;
}