Cod sursa(job #1496005)

Utilizator daniel.grosuDaniel Grosu daniel.grosu Data 4 octombrie 2015 02:14:03
Problema Elementul majoritar Scor 90
Compilator cpp Status done
Runda Arhiva educationala Marime 1.58 kb
#define REP(a,b) for(int a=0; a<(b); ++a)
#define REP2(a,b) for(int a=1; a<=(b); ++a)
#define FWD(a,b,c) for(int a=(b); a<(c); ++a)
#define BCK(a,b,c) for(int a=(b)-1; a>=(c); --a)
#define BCK2(a,b,c) for(int a=(b); a>(c); --a)
#define FWDS(a,b,c,d) for(int a=(b); a<(c); a+=d)
#define ALL(a) (a).begin(), (a).end()
#define SIZE(a) ((int)(a).size())
#define VAR(x) #x ": " << x << " "
#define FILL(x,y) memset(x,y,sizeof(x))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define x first
#define y second
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define l(n) (n<<1)
#define r(n) ((n<<1)+1)
#define f(n) (n>>1)
#define lsb(a) (a&-a)

#include<vector>
#include<stack>
#include<unordered_map>
#include<queue>
#include<algorithm>

using namespace std;
#ifndef ONLINE_JUDGE
#include<fstream>
ifstream cin("elmaj.in");
ofstream cout("elmaj.out");
#else
#include<iostream>
#endif

const int NMAX = 300050;
const int PMAX = 1015;
const int INF = 1 << 31;
const int dx[] = {0, 0, -1, 1}; //1,1,-1,1};
const int dy[] = {-1, 1, 0, 0}; //1,-1,1,-1};

typedef long long LL;
typedef pair<int, int> PII;
typedef long double K;
typedef pair<K, K> PKK;
typedef vector<int> VI;

unordered_map<int, int> M;
 
int a,n;
int main() {
    FAST;
    cin>>n;
    REP(i,n)
    {
        cin>>a;
        M[a]++;
    }
    for(unordered_map<int,int>::iterator it=M.begin(); it!=M.end(); it++)
        if(it->second >= n/2 + 1)
        {
            cout<<it->first<<" "<<it->second;
            return 0;
        }
    return 0;
}