Pagini recente » Progresii 3 | Cod sursa (job #1557194) | Diferente pentru problema/chocolate intre reviziile 6 si 9 | Diferente pentru problema/arborex intre reviziile 3 si 8 | Cod sursa (job #2094157)
#include <iostream>
#include <algorithm>
#include <map>
#include <fstream>
using namespace std;
int main(void)
{
ifstream inp("elmaj.in");
ofstream out("elmaj.out");
if(inp.is_open() && out.is_open())
{
map<int, int> hashtable;
int n;
inp >> n;
for(int i = 0; i < n; i++)
{
int t;
inp >> t;
hashtable[t]++;
}
map<int, int>::iterator it;
for(it = hashtable.begin(); it != hashtable.end(); it++)
{
if(it->second >= (n/2 + 1))
{
out << it->first << " " << it->second;
break;
}
}
inp.close();
out.close();
}
else
{
cout << "error\n";
}
return 0;
}