fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. int main() {
  6. int t; cin >> t;
  7. while(t--){
  8. int n,x; cin >> n;
  9. unordered_map<int,int> f;
  10. for(int i=0;i<n;i++){
  11. cin >> x;
  12. f[x]++;
  13. }
  14. int mx = 0;
  15. for(auto it = f.begin();it != f.end();++it){
  16. mx = max(mx,it->second);
  17. }
  18. cout << n-mx << endl;
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 5268KB
stdin
3
5
5 4 4 3 3
3
2 2 1
1
1
stdout
3
1
0