代码练习
#include <iostream>
#include <unordered_map>
using namespace std;
int n;
unordered_map<int, int> freq;
int main(void) {
scanf("%d", &n);
int max_freq = 0;
while (n--) {
int x;
scanf("%d", &x);
max_freq = max(max_freq, ++freq[x]);
}
int ans = 0;
for (auto&& [num, count] : freq)
if (count == max_freq)
if (num > ans) ans = num;
printf("%d\n", ans);
}