-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.cpp
56 lines (49 loc) · 1.31 KB
/
A.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()
#define X first
#define Y second
#define forn(x, y, z) for(ll (z) = (x); (z) < (y); (z)++)
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << H << ' ';
debug_out(T...);
}
int constexpr N = 1e5;
int constexpr MOD = 1e9 + 7;
int constexpr INF = 1e9;
int main() {
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
vector<int> in(n);
forn (0, n, i) cin >> in[i];
sort(all(in));
vector<vector<int>> gp;
vector<char> mark(n, 0);
forn (0, n, i) {
if (!mark[i]) {
gp.resize(gp.size() + 1);
gp.back().push_back(i);
mark[i] = 1;
forn (i + 1, n, j) {
if (!mark[j] && in[gp.back().back()] + 2 <= in[j]) {
gp.back().push_back(j);
mark[j] = 1;
}
}
}
}
// for (auto i : gp) {
// for (auto j : i) cout << j << ' ';
// cout << '\n';
// }
cout << gp.size() << '\n';
}
return 0;
}