Pagini recente » Cod sursa (job #1195809) | Cod sursa (job #2337105) | Cod sursa (job #2305728) | Cod sursa (job #1498623) | Cod sursa (job #2787835)
#include <bits/stdc++.h>
using namespace std;
ifstream in("elmaj.in");
ofstream out("elmaj.out");
map < int , int > m;
int n;
void prg()
{
in>>n;
for(int i=1;i<=n;i++)
{
int x;
in>>x;
++m[x];
}
map<int, int>::iterator itr;
for (itr = m.begin(); itr != m.end(); ++itr)
{
{
if((*itr).second>=n/2+1)
{
out<<(*itr).first<<' '<<(*itr).second;
in.close();
out.close();
return ;
}
}
}
in.close();
out.close();
out<<-1;
return ;
}
int main()
{
prg();
in.close();
out.close();
return 0;
}
/*
#include <bits/stdc++.h>
using namespace std;
ifstream f("map.in"); ofstream g("map.out");
map <long long, int> m;
int main()
{ int n;
f>>n;
while(n--)
{ long long x;
f>>x; g<<++m[x]<<' ';
}
g.close(); return 0;
}
*/