排序 + 枚举
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
int n;
int a[N];
int main()
{
cin >> n;
for (int i = 0; i < n; i ++ ) cin >> a[i];
sort(a, a + n);
int h = 0;
for (int i = n - 1; ~i; i -- )
if (a[i] > h) h ++ ; //从后往前遍历,每有一个数大于h,h就自增1
cout << h << endl;
return 0;
}