Codeforces 1335C - Two Teams Composing Solution

  1. Solution in C++:
  2. ///**********ALLAH IS ALMIGHTY************///
  3. ///AH Tonmoy
  4. ///Department of CSE,23rd batch
  5. ///Islamic University,Bangladesh
  6. #include<iostream>
  7. #include <algorithm>
  8. #include <map>
  9. using namespace std;
  10. int main()
  11. {
  12. int t,n,i,j,a,mx,f,mr,ms,r;
  13. cin>>t;
  14. while(t--)
  15. {
  16. mr=0,ms=0;
  17. map<int,int>m;
  18. cin>>n;
  19. for(i=0; i<n; i++)
  20. {
  21. cin>>a;
  22. m[a]++;
  23. mr=max(mr,m[a]);
  24. }
  25.  
  26. ms=m.size();
  27. r=max(min(ms,mr-1),min(mr,ms-1));
  28. cout<<r<<endl;
  29. r=0;
  30. }
  31. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.