题解 | 小欧的数组修改

#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")

全部评论

相关推荐

积极的小学生不要香菜:你才沟通多少,没500不要说难
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务