Pagini recente » Cod sursa (job #1143117) | Cod sursa (job #1444534) | Cod sursa (job #2179524) | Cod sursa (job #2289719) | Cod sursa (job #2133943)
#include <bits/stdc++.h>
using namespace std;
map<int,int> Freq;
int N,max_el;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int main(){
ios_base::sync_with_stdio(0);
fin.tie(0);
fin >> N;
for (int i = 1; i <= N;i++){
int x;
fin >> x;
Freq[x]++;
if (Freq[x] > Freq[max_el])max_el = x;
}
if (Freq[max_el] >= N/2 +1) fout <<max_el<<" "<<Freq[max_el];
return 0;
}