Y • 29天前
using namespace std;
const int N = 1000010; int a[N], t[N];
int main() {
int n;
cin >> n;
int x;
for (int i = 0; i < n; i++) {
cin >> x;
t[x]++;
}
int i = 0, j = 0;
while (j <= n) {
while (t[j] && i <= j) {
i++;
t[j]--;
}
j++;
}
cout << i;
return 0;
}
评论:
请先登录,才能进行评论