Pagini recente » Cod sursa (job #2797157) | Cod sursa (job #2392882) | Cod sursa (job #2393207) | Cod sursa (job #2330267) | Cod sursa (job #2788036)
#include <bits/stdc++.h>
using namespace std;
ifstream f("elmaj.in"); ofstream g("elmaj.out");
int n,v[1000001];
int main()
{ f>>n;
for(int i=1;i<=n;i++) f>>v[i];
sort(v+1,v+n+1);
for(int i=1;i<=n;++i)
{ int j=i;
while(j<=n && v[i]==v[j+1]) j++;
if(j-i+1>n/2) {g<<v[i]<<' '<<j-i+1; g.close(); f.close(); return 0;}
}
g<<-1; g.close(); f.close(); return 0;
}