Ankit_132

A

Jun 26th, 2024
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int t;
  7.     cin >> t;
  8.     while(t--){
  9.         int n;
  10.         cin >> n;
  11.        
  12.         int A[n];
  13.         for (int i = 0; i < n; i++)
  14.             cin >> A[i];
  15.        
  16.         int f = 1;
  17.        
  18.         sort(A, A + n);
  19.        
  20.         for (int i = 0; i < n; i++) {
  21.             if (A[i] > i + 1)
  22.                 f = 0;
  23.         }
  24.        
  25.         if (f)
  26.             cout << "YES"<<endl;
  27.         else
  28.             cout << "NO"<<endl;
  29.        
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment