Cod sursa(job #1461248)

Utilizator bublesbubles tiganu bubles Data 15 iulie 2015 11:08:49
Problema Elementul majoritar Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.29 kb
#include <fstream>

using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");

int main(){
    int n, v[1000000], x, max=0;
    fin >> x;
    while(fin>>x){
    v[x]++;
    if(max < v[x])
        max = v[x];
        n = x;
    }
    fout << n << " " << max;

    return 0;
}