-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
39 lines (37 loc) · 893 Bytes
/
Copy pathB.cpp
File metadata and controls
39 lines (37 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define X first
#define Y second
int main() {
ios::sync_with_stdio(0), cin.tie(0);
// cout << fixed << setprecision(15);
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(all(a));
int cnt = 0;
for (int i = 0; i < n; ) {
bool filled = false;
int mx = a[i], sz = 1;
i++;
while (i <= n && !filled) {
if (mx == sz) {
filled = true;
break;
}
if (i == n) break;
mx = max(a[i], mx);
sz++;
i++;
}
cnt += filled;
}
cout << cnt << '\n';
}
return 0;
}