Pagini recente » Cod sursa (job #731974) | Cod sursa (job #1862986) | Cod sursa (job #1395901) | Cod sursa (job #1795279) | Cod sursa (job #2525119)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream in("elmaj.in");
ofstream out("elmaj.out");
int main()
{
int n;
static int v[1000001];
in>>n;
for(int i=0;i<n;i++)
{
in>>v[i];
}
sort(v,v+n);
int combo=0,max=-1,maj,a,b;
for(int i=1;i<n;i++)
{
if(v[i]==v[i-1])
{
combo++;
}
else
{
combo++;
if(combo>max)
{
max=combo;
a=v[i-1];
}
combo=0;
}
}
if(v[n-1]==v[n-2])
{
combo++;
if(combo>max)
{
max=combo;
a=v[n-1];
}
}
else
{
if(1>max)
{
max=combo;
a=v[n-1];
}
}
out<<a<<" "<<max;
return 0;
}