Pagini recente » Cod sursa (job #2377704) | Cod sursa (job #1914081) | Cod sursa (job #1417216) | Cod sursa (job #2082555) | Cod sursa (job #2708720)
/******************************************************************************
{1}
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
{1}
*******************************************************************************/
#include <stdio.h>
#include <iostream>
#include <map>
using namespace std;
map <int,int>m;
int main()
{
freopen("elmaj.in","r",stdin);
freopen("elmaj.out","w",stdout);
int n,nr,c=0,cc=-1;
scanf("%i",&n);
for(int i=0;i<n;i++)
{
scanf("%i",&nr);
m[nr]++;
if(cc==-1)
{
cc=nr;
}
if(cc==nr) c++;
if(cc!=nr) c--;
if(c<0)
{
c=-c;
cc=nr;
}
}
if(c<1||m[cc]<(n/2+1)) printf("-1");
else printf("%i %i",cc,m[cc]);
return 0;
}