Pagini recente » Cod sursa (job #1766951) | Cod sursa (job #3138229) | Cod sursa (job #1368367) | Cod sursa (job #2113653) | Cod sursa (job #1843729)
#include <bits/stdc++.h>
using namespace std;
//ifstream f("elmaj.in");
//ifstream h("elmaj.in");
ofstream g("elmaj.out");
int n,i,e,cnt,x,poz;
char buff[1010];
const int DIM=1000;
void citeste(int &);
int main()
{
freopen("elmaj.in","rb",stdin);
citeste(n);
citeste(e);
cnt=1;
for(i=2;i<=n;i++)
{
citeste(x);
if(cnt==0)
e=x,cnt=1;
else
if(e==x)
cnt++;
else
cnt--;
}
cnt=0;
fclose(stdin);
freopen("elmaj.in","rb",stdin);
memset(buff,0,sizeof(buff));
citeste(n);
for(i=1;i<=n;i++)
{
citeste(x);
if(x==e)
cnt++;
}
if(cnt>n-cnt)
g<<e<<' '<<cnt;
else
g<<-1;
return 0;
}
void citeste(int &numar)
{
numar = 0;
while (buff[poz] < '0' || buff[poz] > '9')
if (++poz == DIM)
fread(buff,1,DIM,stdin),poz=0;
while ('0'<=buff[poz] && buff[poz]<='9')
{
numar = numar*10 + buff[poz] - '0';
if (++poz == DIM)
fread(buff,1,DIM,stdin),poz=0;
}
}