Pagini recente » Cod sursa (job #2955502) | Cod sursa (job #1117708) | Cod sursa (job #1327724) | Cod sursa (job #2394694) | Cod sursa (job #2418095)
#include <fstream>
#include <map>
using namespace std;
ifstream in("elmaj.in");
ofstream out("elmaj.out");
int main()
{
ios_base::sync_with_stdio(0);
in.tie(0);
int n;
in >> n;
map<int,int> m;
int el = 0;
for(int i = 0; i < n; i++)
{
int tmp;
in >> tmp;
if(++m[tmp] >= n/2 + 1) el = tmp;
}
if(el) out << el << ' ' << m[el];
else out << -1;
return 0;
}