https://codeforces.com/contest/1335
C
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; } }