Question Link:- https://codeforces.me/contest/1506/problem/D
My Solution:- int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t; cin>>t; while(t--) {
int n,x=0,d=1;
cin>>n; int a[n]; int count=1; for(int i=0;i<n;i++) { cin>>a[i];
}
sort(a,a+n); for(int i=0;i<n-1;i++) { if(a[i]==a[i+1]) { count++; } else {d++; if(x<count) { x=count; }
count=0; } } if(x==n/d&&n%2==0) { cout<<"0"<<endl; } else cout<<abs((2*x)-n)<<endl;
} return 0; }
Getting wrong answer on 2nd test case .