题解 | 小欧的数组修改
#include <iostream> #include <map> #include <vector> using namespace std; int main() { int n; cin >> n; int temp = 0; map<int, int> mp; for (int i = 0; i < n; i ++) { cin >> temp; mp[temp] ++; } int max_count = 0; for (auto& it : mp) { if (it.second >= max_count) { max_count = it.second; } } // 所有元素都一样 if (mp.size() == 1) { cout << max_count << endl; } else { cout << max_count + 1 << endl; } } // 64 位输出请用 printf("%lld")