Pagini recente » Cod sursa (job #794777) | Borderou de evaluare (job #888964) | Cod sursa (job #2579600) | Cod sursa (job #2303466) | Cod sursa (job #2183915)
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
int ap[110017][2];
const int M=110017;
int h(int x)
{
return x%M;
}
int main()
{
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
vector < int > v[110017];
int p, n, i, j, ind, max, apmax=0, x;
fin >> n;
for (i=0; i<n; i++)
{
fin >> x;
p=0;
ind=h(x);
for (j=0; j<v[ind].size(); j++)
if (x==v[ind][j])
p=1;
if (ap[ind][0]==0)
{
ap[ind][0]=1;
ap[ind][1]=x;
}
else if (ap[ind][1]==x)
ap[ind][0]++;
}
p=0;
for (i=0; i<110017; i++)
{
if (p)
break;
if (ap[i][0]>n/2)
{
p=1;
apmax=ap[i][0];
max=ap[i][1];
}
}
if (p)
fout << max << " " << apmax;
else
fout << -1;
return 0;
}