Pagini recente » Cod sursa (job #3216261) | Cod sursa (job #79710) | Cod sursa (job #1172313) | Cod sursa (job #1940210) | Cod sursa (job #1324033)
#include <fstream>
using namespace std;
int v[100000000];
int main()
{
ifstream f("elmaj.in");
ofstream g("elmaj.out");
int n,x,i,j,cont=1,ok=0,aux;
f>>n;
for(i=0;i<n;++i)
f>>v[i];
for(i=0;i<n-1;++i)
for(j=i+1;j<n;++j)
if(v[i]>v[j])
{
aux=v[i];
v[i]=v[j];
v[j]=aux;
}
for(i=1;i<n;++i)
if(v[i]==v[i-1])
cont++;
else
{if(cont>=(n/2+1))
{g<<v[i-1]<<' '<<cont;ok=1;break;}
cont=1;}
if(!ok)
g<<"-1";
return 0;
}