Pagini recente » Cod sursa (job #377571) | Cod sursa (job #513082) | Cod sursa (job #712297) | Cod sursa (job #606851) | Cod sursa (job #1050303)
#include <iostream>
#include <fstream>
#include <unordered_map>
//#include <map>
std::ifstream fin("elmaj.in");
std::ofstream fout("elmaj.out");
int n;
std::unordered_map<int, int> aparitii;
//std::map<long long, int> aparitii;
void citire()
{
fin>>n;
long long x;
long long maxim = -1, indice;
for(int i = 0; i < n; i++)
{
fin>>x;
aparitii[x]++;
if(aparitii[x] > maxim)
{
maxim = aparitii[x];
indice = x;
}
// if(maxim >= n / 2 + 1)
// {
// break;
// }
}
if(maxim >= n / 2 + 1)
{
fout<<indice<<' '<<maxim<<'\n';
}
else
{
fout<<-1<<'\n';
}
}
void rezolvare()
{
}
int main()
{
citire();
rezolvare();
return 0;
}