#include <iostream>
#include<algorithm>
using namespace std;
int a[100001];
bool cmp(int a,int b) {
if (a > b)
return true;
else
return false;
}
int main()
{
int n,i;
bool flag=false;
cin >> n;
for ( i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n,cmp);
for ( i = 0; i < n; i++) {
if (a[i] <= i + 1)
break;
}
cout << i ;
}
用sort函数降序排列,比如10,9,8,8,7,7,6,6。10对应1天超过1英里,9对应2天超过两英里,以此类推,直到6的适合,6小于等于7,那么跳出for循环,这时i的值即为题目所求的值。