题意:每个人有一个
a
i
a_i
ai,只有当已经在场上的人大于
a
i
a_i
ai时,这个人才能上场,需要注意的是场上初始时就有一个人。
思路:显然,
a
i
a_i
ai小的人会更早上场,所以我们可以先排一遍序,当
i
i
i大于
a
i
a_i
ai时就意味前
i
i
i个人都可以上场。
代码:
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair <int, int> PII;
const int N = 2e5 + 10;
const ll mod = 1e9 + 7;
int t, n, a[N];
int main() {
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
sort(a + 1, a + 1 + n);
int res = 1;
for(int i = 1; i <= n; i++) {
if(i >= a[i]) {
res = i + 1;
}
}
printf("%d\n", res);
}
return 0;
}