As the answer of the “chef and equality” problem i wrote this code. It is giving correct answer,stil wrong answer is being shown…why?
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int t,i,j,s1=0,maxi=0;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);i=0;
while(i<n)
{
j=i+1;s1=1;
while(a[i]==a[j])
{
s1++;
j++;
}
if(s1>maxi){maxi=s1;}
i=j;
}
cout<<n-maxi<<endl;
}
return 0;
}