Pagini recente » Cod sursa (job #1012487) | Diferente pentru problema/ordonare intre reviziile 8 si 9 | Cod sursa (job #2670549) | Cod sursa (job #2862362) | Cod sursa (job #1238564)
#include <iostream>
#include <fstream>
using namespace std;
int a[86]={0};
int main()
{
ifstream f("elmaj.in");
ofstream g("elmaj.out");
int n,ok=1,mx=0,x;
f >> n;
f >> x;
mx=x;
for(int i=1;i<=n-1;++i)
{
f >> x;
if(ok==0)
{
mx=x;
}
if(x==mx)
{
++ok;
}
else --ok;
}
if(ok) g << mx <<" " << (n/2)+ok;
else g << "-1";
return 0;
}