Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define ff first
- #define ss second
- #define pb push_back
- #define ppb pop_back
- int main()
- {
- _test
- {
- int n;
- cin>>n;
- vector<int> a(n);
- for(auto &e: a) cin>>e;
- map<int, int> cnt;
- for(auto e: a)
- cnt[e]++;
- int f = 1;
- if(*max_element(a.begin(), a.end()) > n) f = 0;
- for(int i=1; i<=n; i++)
- {
- if(cnt[i] > cnt[i-1])
- f = 0;
- }
- if(f) cout<<"YES\n";
- else cout<<"NO\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment