Cod sursa(job #1018414)
Utilizator | Data | 29 octombrie 2013 15:51:44 | |
---|---|---|---|
Problema | Elementul majoritar | Scor | 30 |
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 f[1000025],n,elmaj,nr,x;
int main(){
in>>n;
for(int i=1;i<=n;++i){
in>>x;
f[x]++;
if(f[x]>nr){ nr=f[x]; elmaj=x;}
}
out<<elmaj<<' '<<f[x]<<'\n';
out.close(); return 0;
}