ac

Mathematics  •  7天前


include<stdio.h>

void qusort(int a[],int start,int end) {

int i,j,temp,temp1,t;
if(start<end)
{
	i=start;
	j=end;
	temp=a[start];
	while(i<j){
	
	while(a[j]>temp&&i<j)
	{
		j--;
	}
	while(a[i]<=temp&&i<j)
	{
		i++;
	}
		t=a[i];
		a[i]=a[j];
		a[j]=t;
}
a[start]=a[i];
a[i]=temp;
qusort(a,start,i-1);
qusort(a,i+1,end);
}
else
{
	return;
}

} int main() {

int n,a[1000005]={0},count=0;
int day=1;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
	scanf("%d",&a[i]);
}
qusort(a,1,n);
for(int j=1;j<=n;j++)
{
	if(a[j]+1>=day)
	{
		count++;
		day++;
	}
	else
	{
		continue;
	}
	
}
printf("%d",count);

return 0;

}


评论:

请先登录,才能进行评论