Pagini recente » Cod sursa (job #1616146) | Cod sursa (job #1619824) | Cod sursa (job #1109014) | Cod sursa (job #3168263) | Cod sursa (job #638615)
Cod sursa(job #638615)
using namespace std;
//#include <cstdio>
#include <fstream>
int main() {
// freopen("elmaj.in", "r", stdin);
// freopen("elmaj.out", "w", stdout);
fstream fin("elmaj.in", fstream::in);
fstream fout("elmaj.out", fstream::out);
int n;
int el, count;
int a[1000000], el_count;
// scanf("%d\n", &n);
fin >> n;
el = -1;
count = 0;
for (int i = 0 ; i < n ; i++) {
// scanf("%d ", &n_el);
fin >> a[i];
if (a[i] == el)
count++;
else
if (count > 0)
count--;
else {
el = a[i];
count = 1;
}
}
el_count = 0;
for(int i = 0 ; i < n ; i++)
if (a[i] == el)
el_count ++;
fout << el << " " << el_count;
return 0;
}