Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main() {
- // https://www.codechef.com/problems/EQDIFFER
- int t;
- cin>>t;
- while(t--){
- ll n;
- cin>>n;
- ll a[n];
- map <ll,ll> mp;
- set <ll> s;
- for (ll i=0; i<n; i++){
- cin>>a[i];
- mp[a[i]]++;
- s.insert(a[i]);
- }
- if (n<=2 || s.size()==1) cout<<0<<"\n";
- else {
- tuple <ll,ll> p[n];
- for (int i=0; i<n; i++){
- get<1>(p[i])=a[i];
- get<0>(p[i])=mp[a[i]];
- }
- sort(p,p+n);
- cout<<n-get<0>(p[n-1])<<"\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement