Files
exercises/cs101/dh_01_05_vote.cpp
T
2026-09-28 14:05:06 +08:00

29 lines
476 B
C++

#include <iostream>
using namespace std;
constexpr int MAX_X = 15;
int n, winner;
unsigned int bucket[MAX_X + 1];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int _ = 0; _ < n; _++) {
int x;
cin >> x;
bucket[x]++;
}
winner = 0;
for (int x = 1; x <= MAX_X; x++) {
if (bucket[x] > bucket[winner]) {
winner = x;
}
}
cout << winner << endl;
return 0;
}