C 二分
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n,m;
cin>>n>>m;
map<int,int>mp;
for(int i=1;i<=n;i++){
mp[i]=0;
}
for(int i=1;i<=m;i++){
int temp;
cin>>temp;
mp[temp]++;
}
int l=1,r=2*m;
while(l<r)
{
int mid=l+r>>1;
long long fr=0,need=0;
for(auto eg:mp){
if(mid>=eg.second)fr+=(mid-eg.second)/2;
else need+=eg.second-mid;
}
if(need<=fr)r=mid;
else l=mid+1;
}
cout<<r<<"\n";
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
}