Pagini recente » Cod sursa (job #440172) | Cod sursa (job #2960324) | Cod sursa (job #1429060) | Cod sursa (job #766278) | Cod sursa (job #1120686)
/// Craciun Catalin
/// Map (libraria map.h)
#include <fstream>
#include <iostream>
#include <map>
#define NMax 1000000
using namespace std;
ifstream f("elmaj.in");
ofstream g("elmaj.out");
map<long, long> C;
long n;
long A[NMax];
void elmaj()
{
f>>n;
for (long i=0;i<n;i++)
{
f>>A[i];
C[A[i]]++;
}
for (long i=0;i<n;i++)
if (C[A[i]]>n/2)
{
g<<A[i]<<' '<<C[A[i]]<<'\n';
g.close();
break;
}
}
int main()
{
elmaj();
return 0;
}