Pagini recente » Cod sursa (job #2225735) | Cod sursa (job #1358535) | Cod sursa (job #1991214) | Cod sursa (job #833936) | Cod sursa (job #3310824)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int n,v[1000000], candihdat, frec, nr;
int main(){
fin>>n;
for(int i = 1;i<=n;i++){
fin >> v[i];
}
candihdat=v[1];
for(int i = 2;i<=n;i++){
if(candihdat==v[i]){
frec++;
}
if(candihdat!=v[i]){
frec--;
}
if(frec==0){
candihdat=v[i];
}
}
for(int i = 1;i<=n;i++){
if(candihdat == v[i]){
nr++;
}
}
fout << candihdat << " " << nr;
}