Pagini recente » Cod sursa (job #596660) | Atasamentele paginii gimnaziu_1 | Cod sursa (job #1656195) | Cod sursa (job #3260178) | Cod sursa (job #2220541)
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream cin("elmaj.in");
ofstream cout("elmaj.out");
int main()
{
unordered_map<int, int> m;
int n, x;
cin >> n;
int max = n/2 + 1;
int el = -1;
for(int i = 0; i < n; i++)
{
cin >> x;
m[x]++;
if(m[x] >= max)
{
max = m[x];
el = x;
}
}
if(el != -1)
cout << el << " " << m[el];
else
cout << -1;
}