Pagini recente » Cod sursa (job #254540) | Cod sursa (job #1508468) | Cod sursa (job #374194) | Cod sursa (job #146554) | Cod sursa (job #703652)
Cod sursa(job #703652)
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
ifstream in("elmaj.in");
ofstream out("elmaj.out");
struct el {
int nr,val;
};
int n,smax,elmax;
vector<el> h[666013];
inline int ha(int nr) {
return nr%666013;
}
inline void add(int poz,int val) {
el tm;
int po = ha(poz);
vector<el>::iterator it;
tm.nr = poz; tm.val = val;
for(it=h[po].begin();it!=h[po].end();++it)
if(it->nr == poz) {
it->val+=val;
if(it->val > smax) {
elmax = it->nr;
smax = it->val;
}
return;
}
h[ha(poz)].push_back(tm);
}
int main() {
int i,x;
in >> n;
for(i=1;i<=n;++i) {
in >> x;
add(x,1);
}
out << elmax << " " << smax << "\n";
return 0;
}