This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;//题单数量上限
int a[N];//每套题单里面的题的数量
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
sort(a + 1, a + 1 + n);
int h = 1;//排完序后,待比较的题单号
for (int i = 1;;) { //枚举每一天,依赖break停止
if (a[h] >= i) //允许,可以走到一天
i++;
if (++h > n) {
cout << i - 1 << endl;
break;
}
return 0;