Pagini recente » Cod sursa (job #1500825) | Cod sursa (job #320218) | Cod sursa (job #1250008) | Cod sursa (job #311995) | 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;
}