Codeforces 1335C - Two Teams Composing Solution
- Solution in C++:
- ///**********ALLAH IS ALMIGHTY************///
- ///AH Tonmoy
- ///Department of CSE,23rd batch
- ///Islamic University,Bangladesh
- #include<iostream>
- #include <algorithm>
- #include <map>
- using namespace std;
- int main()
- {
- int t,n,i,j,a,mx,f,mr,ms,r;
- cin>>t;
- while(t--)
- {
- mr=0,ms=0;
- map<int,int>m;
- cin>>n;
- for(i=0; i<n; i++)
- {
- cin>>a;
- m[a]++;
- mr=max(mr,m[a]);
- }
- ms=m.size();
- r=max(min(ms,mr-1),min(mr,ms-1));
- cout<<r<<endl;
- r=0;
- }
- }
No comments