![](https://img-blog.csdnimg.cn/20210817182729106.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzUzNDAzMjM4,size_16,color_FFFFFF,t_70)
![](https://img-blog.csdnimg.cn/20210817202537213.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzUzNDAzMjM4,size_16,color_FFFFFF,t_70)
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
int n, m;
cin >> n >> m;
assert(m >= 1 && m <= n && n <= 100000);
vector<int> f(n + 2);
f[n + 1] = 1;
while (m--) {
int v;
cin >> v;
assert(v >= 1 && v <= n);
assert(f[v] == 0);
f[v] = 1;
}
vector<pair<int, int>> size;
int have = 0;
int count = 0;
for (int i = 1; i <= n + 1; i++) {
if (f[i]) {
if (have) {
size.push_back(make_pair(have, count));
}
have = 0;
count += 1;
} else {
have += 1;
}
}
sort(size.begin(), size.end());
if (size.empty()) {
cout << "YES\n";
continue;
}
int sum = 0;
for (auto s: size) {
sum += s.first;
}
if (size.back().first <= sum - size.back().first + size.back().second) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}