-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMEXreordering.cpp
More file actions
39 lines (35 loc) · 766 Bytes
/
MEXreordering.cpp
File metadata and controls
39 lines (35 loc) · 766 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;
using ll = long long;
int main(){
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
vector<ll> a(n);
for(ll i=0;i<n;i++){
cin>>a[i];
}
string ans="YES";
sort(a.begin(),a.end());
for(ll i=0; i<n; i++){
ll mexa=0; ll mexb=0;
for(ll j=0; j<=i; j++){
if(a[j]==mexa ) {
mexa++;
}
}
for(ll j=i+1; j<n; j++){
if(a[j]==mexb){
mexb++;
}
}
if(mexa==mexb){
ans="NO";
break;
}
}
cout<<ans<<endl;
}
}