Pagini recente » Cod sursa (job #3213944) | Cod sursa (job #2725636) | Cod sursa (job #206820) | Cod sursa (job #2842767) | Cod sursa (job #734751)
Cod sursa(job #734751)
#include <iostream>
#include <fstream>
using namespace std;
long v[1000001];
int main()
{
long max1=-1,max2=-1,n,x;
int ok=0;
ifstream f;
ofstream g;
f.open("elmaj.in");
f>>n;
while (f>>x) {v[x]++;
if (v[x]==v[max2]&&x!=max2) ok=0;
if (v[x]>max1) {max1=v[x]; max2=x; ok=1;}
}
f.close();
g.open("elmaj.out");
if (ok) g<<max2<<' '<<max1;
else g<<-1;
g.close();
return 0;
}