-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdcepca10.cpp
41 lines (41 loc) · 915 Bytes
/
dcepca10.cpp
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
37
38
39
40
41
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int t,n,count,i,max,j,k;
cin>>t;
while(t--){
cin>>n;
int a[n];
for(i=0;i<n;i++)
cin>>a[i];
if(n==1)
max=2;
else{
sort(a,a+n);
max=1;
count=0;
for(i=0;i<n-1;i++){
if(a[i]==a[i+1]){
k=a[i];
for(j=i+2;j<n;j++){
if(a[j]!=k)
break;
}
count = j-i;
i=j-1;
}
if(count>max){
max=count;
cout<<max<<endl;
}
}
}
if(max>=(n/2+1))
cout<<0<<endl;
else
cout<<n/2+1-max<<endl;
}
system("pause");
return 0;
}