Pagini recente » Cod sursa (job #986318) | Cod sursa (job #2225813) | Cod sursa (job #615501) | Cod sursa (job #2549631) | Cod sursa (job #1987860)
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <climits>
#include <map>
#define ll long long
#define pb push_back
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
const int NLIM = 1e6 + 10;
int N;
map< int, int > m;
int elmaj = -1;
int main()
{
ios::sync_with_stdio( false );
fin >> N;
for( int i = 0; i < N; ++i )
{
int x;
fin >> x;
m[x] += 1;
if( m[x] >= ( ( N / 2 ) + 1 ) )
elmaj = x;
}
fout << elmaj << " ";
if( elmaj != -1 )
fout << m[elmaj];
return 0;
}