首页 > 其他 > 详细

cf634div3

时间:2020-04-14 10:07:45      阅读:48      评论:0      收藏:0      [点我收藏+]

https://codeforces.com/contest/1335

n个数字选取一部分分为数量相等的两组,一组全部一样,另一组都不一样

求最大的元素个数

#include<bits/stdc++.h>

using namespace std;
map<int, int> mp;
int t;

int main() {
    ios::sync_with_stdio(0);
    cin >> t;
    while (t--) {
        mp.clear();
        int x, n, maxx = 0;
        cin >> n;
        for (int i = 0; i < n; i++) {
            cin >> x;
            mp[x]++;
            if (mp[x] > maxx)
                maxx = mp[x];
        }
        int y = mp.size();
        if (maxx == y)
            maxx--;
        cout << min(maxx, y) << endl;

    }
}

 

cf634div3

原文:https://www.cnblogs.com/xcfxcf/p/12695547.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!