链接:https://codeforces.ml/problemset/problem/1506/D
题意:找到两个不同的数就可以消掉,最少剩几个;
题解:水题,具体看代码;大概就是优先把最多的数字消掉;
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int num[100005];
int main()
{
int t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
map<ll, ll> mp;
ll mx = 0, x;
for (int i = 0; i < n; i++)
{
cin >> x;
mx = max(mx, ++mp[x]);
}
ll cnt = n - mx;
if (mx >= cnt)
cout << mx - cnt << endl;
else
cout << (cnt - mx) % 2 << endl;
}
}