Cod sursa(job #1051614)

Utilizator stanescu.raduRadu Stanescu stanescu.radu Data 10 decembrie 2013 12:32:47
Problema Elementul majoritar Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.41 kb
#include<fstream>
#include<unordered_map>

using namespace std;

ifstream f ("elmaj.in");
ofstream g("elmaj.out");

unordered_map <int,int> map;
unordered_map <int,int> :: iterator l;

int n,i,x,maxx;

int main ()
{
	f >> n;
	maxx = 0;
	for (i = 1; i <= n; i++)
	{
		f >> x;
		map[x]++;
		if (map[x] > maxx)
			maxx = x;
	}
	g << maxx << " " << map[maxx];
	f.close();
	g.close();
	return 0;
}