forked from Sanchitbajaj02/CppPrograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoves.cpp
More file actions
36 lines (33 loc) · 693 Bytes
/
moves.cpp
File metadata and controls
36 lines (33 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long int t,n;
cin>>t;
while(t--)
{
cin>>n;
long long int i,a[n];
for(i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
map<int,int> m;
for(i=0;i<n;i++)
{
m[a[i]]++;
}
int max=0,cmax=0,s=0;
map<int,int>::iterator j;
for(j=m.begin();j!=m.end();j++)
{
if(j->second>cmax)
{max=j->first;cmax=j->second;}
}
for(j=m.begin();j!=m.end();j++)
{
if(j->first!=max)
s=s+j->second;
}
cout<<s<<endl;
}
}