Pagini recente » Cod sursa (job #3210731) | Cod sursa (job #2986770) | Cod sursa (job #1631844) | Cod sursa (job #1568745) | Cod sursa (job #2952618)
#include <fstream>
using namespace std;
ifstream cin("elmaj.in");
ofstream cout("elmaj.out");
long long int v[1000005];
int main()
{
int n ,f;
long long int c;
cin >> n >> v[1];
c=v[1];
f = 1;
for(int i=2; i<=n ; i++)
{
cin>>v[i];
if(v[i]==c) f++;
else
{
f--;
if(f)
{
c=v[i];
f=1;
}
}
}
f=0;
for(int i=1; i<=n ; i++)
{
if(v[i]==c)f++;
}
if(f>n/2) cout<<c<<' '<<f;
else cout<<-1;
}