Pagini recente » info-arena 2.0 | Cod sursa (job #2917795) | Cod sursa (job #972187) | Cod sursa (job #778998) | Cod sursa (job #1061003)
#include<iostream>
#include<fstream>
#include<vector>
#include<unordered_map>
using namespace std;
int V[1000000];
int main(){
ifstream f("elmaj.in");
ofstream o("elmaj.out");
unordered_map<int, int> hash;
int n = 0; f >> n;
for (int i = 0; i < n; i++){
f >> V[i];
if (hash.find(V[i]) != hash.end()){
hash[V[i]]++;
}
else{
hash[V[i]] = 1;
}
}
for (int i = 0; i < n; i++){
if (hash[V[i]] >= n / 2){
o << V[i] << " " << hash[V[i]];
return 0;
}
}
o << -1;
return 0;
}