Pagini recente » Cod sursa (job #3277156) | Cod sursa (job #2730366) | Cod sursa (job #602374) | Cod sursa (job #722896) | Cod sursa (job #1299571)
#include <fstream>
#define NMax 1000005
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int N,A[2][NMax],Sol;
int main()
{
int k=0;
fin>>N;
for(int i=1; i<=N; i++)
{
int x;
fin>>x;
int Poz = -1;
for(int j=1;j<=k; j++)
if(A[0][j]==x)
Poz=j;
if(Poz!=-1)
A[1][Poz] = A[1][Poz] + 1;
else
{
k++;
A[0][k] = x;
A[1][k] = 1;
}
}
Sol = -1;
for(int i=1;i<=N;i++)
{
if(A[1][i]>=(N+1)/2)
Sol = i;
}
fout<<A[0][Sol]<<" "<<A[1][Sol]<<"\n";
return 0;
}