-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
40 lines (36 loc) · 961 Bytes
/
B.cpp
File metadata and controls
40 lines (36 loc) · 961 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
40
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
using namespace std;
//----------------------Code Starts Here-----------------------------//
const int N = 2e5 + 1;
int p[N];
signed main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<int> v(n);
for (auto &i: v)
cin >> i;
sort(v.begin(), v.end());
if (n == 1 and v[0] >= 2) {
cout << "NO" << endl;
continue;
}
if (n == 1) {
cout << "YES" << endl;
continue;
}
cout<<(v[n-1]-v[n-2] <=1 ? "YES" :"NO")<<endl;
}
}