废话少说,代码如下:
#include<iostream>
using namespace std;
int t,n,x,jj;
int v[1000010];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);//不写会TLE
cin>>t;
while(t--)
{
cin>>n;
for(int i=0; i<=n; i++)
{
v[i]=0;
}
for(int i=1; i<=n; i++)
{
cin>>x;
if(x<=n)
{
v[x]=1;
}
}
jj=0;
while(v[jj]==1)
{
jj++;
}
cout<<min(n,jj)<<'\n';
}
return 0;
}