Cod sursa(job #1018426)
Utilizator | Data | 29 octombrie 2013 16:02:40 | |
---|---|---|---|
Problema | Elementul majoritar | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include<fstream>
using namespace std;
ifstream in("elmaj.in"); ofstream out("elmaj.out");
int n,x,nr=0,el,f[1000010];
int main(){
in>>n;
for(int i=1;i<=n;++i){
in>>x; f[x]++;
if(f[x]>nr){
nr=f[x]; el=x;
}
}
out<<el<<' '<<nr;
out.close();
return 0;
}