Pagini recente » Diferente pentru documentatie/textile intre reviziile 53 si 107 | Rating Truta Bogdan (Bogdan03) | Cod sursa (job #246985) | Diferente pentru home intre reviziile 756 si 902 | Cod sursa (job #2002617)
#include <cstdio>
#include <map>
using namespace std;
map <int, int> nr;
map<int,int>::iterator it;
int main ()
{
FILE *f=fopen("majoritar.in","r");
FILE *g=fopen("majoritar.out","w");
int n,i,x,ok=0;
fscanf(f,"%d",&n);
for(i=0;i<n;i++)
{
fscanf(f,"%d",&x);
nr[x]++;
}
for(it = nr.begin();it!=nr.end();++it)
{
if(it->second>=(n/2)+1)
{
fprintf(g,"%d %d",it->first, it->second);
ok=1;
break;
}
}
if(ok==0)
fprintf(g,"-1");
return 0;
}