Advertisement
fooker

Untitled

Nov 17th, 2022
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. int main() {
  6.     // https://www.codechef.com/problems/EQDIFFER
  7.     int t;
  8.     cin>>t;
  9.     while(t--){
  10.         ll n;
  11.         cin>>n;
  12.         ll a[n];
  13.         map <ll,ll> mp;
  14.         set <ll> s;
  15.         for (ll i=0; i<n; i++){
  16.             cin>>a[i];
  17.             mp[a[i]]++;
  18.             s.insert(a[i]);
  19.         }
  20.         if (n<=2 || s.size()==1) cout<<0<<"\n";
  21.         else {
  22.             tuple <ll,ll> p[n];
  23.             for (int i=0; i<n; i++){
  24.                 get<1>(p[i])=a[i];
  25.                 get<0>(p[i])=mp[a[i]];
  26.             }
  27.             sort(p,p+n);
  28.             cout<<n-get<0>(p[n-1])<<"\n";
  29.            
  30.         }      
  31.     }
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement