美文网首页PTA甲级
1054 The Dominant Color (20 poin

1054 The Dominant Color (20 poin

作者: zilla | 来源:发表于2019-01-20 16:41 被阅读0次

    1054 The Dominant Color

    MAP的插入 你可长点心吧233333

    #include <stdio.h>
    #include <map>
    
    using namespace std;
    
    int main() {
        int m, n, curr, res;
        map<int, int> g;
        scanf("%d%d", &m, &n);
        int num = m * n;
        int half = num / 2;
        for (int i = 1; i <= num; ++i) {
            scanf("%d", &curr);
            g[curr]++;
            if (g[curr] >= half)
                res = curr;
    
        }
        printf("%d\n", res);
        return 0;
    }
    

    相关文章

      网友评论

        本文标题:1054 The Dominant Color (20 poin

        本文链接:https://www.haomeiwen.com/subject/hxnxjqtx.html