0
已解决
杜承俊
资深守护
资深守护
蒟蒻
Wrong Answer:46分
代码:::
#include<bits/stdc++.h>
using namespace std;
const int N=50000+10;
int a[N],b[N],n,cnt;
bool vis[2*N+10];
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++){
cin>>b[i];
vis[b[i]]=true;
}
for(int i=1;i<=2*n;i++)
if(!vis[i])
a[++cnt]=i;
sort(a+1,a+1+n);
sort(b+1,b+1+n);
int l1,r1,l2,r2,ans=0;
l1=l2=1;
r1=r2=n;
while(l1<=r1){
if(a[r1]>b[r2]){
ans++;
r1--,r2--;
}else if(a[l1]>b[l2]){
ans++;
l1++,l2++;
}else{
if(a[l1]>b[r2])ans++;
l1++,r2--;
}
}
cout<<ans;
return 0;
}