解法:
#include<iostream>
#include<algorithm>
#include<vector>
#include<unordered_map>
#include<utility>
using namespace std;
int main() {
int n, a;
cin >> n;
unordered_map<int, int> mp;
while (n--) {
cin >> a;
mp[a]++;
}
pair<int, int> as = { 0,0 };
auto it = mp.begin();
while (it != mp.end()) {
if (it->second > as.first) {
as.first = it->second;
as.second = it->first;
}
if (it->second == as.first) {
as.second = min(as.second, it->first);
}
it++;
}
cout << as.second;
return 0;
}