fork download
  1. #include<bits/stdc++.h>
  2. using namespace std ;
  3. int main() {
  4. int t ;
  5. cin >> t ;
  6. while( t-- ) {
  7. int n ;
  8. cin >> n ;
  9. int fr[101] ;
  10. memset( fr, 0, sizeof fr ) ;
  11. int cnt = 0 ;
  12. int mx = -1 ;
  13. int mn = 101 ;
  14. for( int i = 0 ; i < n ; i++ ) {
  15. int a ;
  16. cin >> a ;
  17. mx = max( mx, a ) ;
  18. mn = min( mn, a ) ;
  19. if( fr[a] == 0 ) {
  20. cnt++ ;
  21. fr[a] = 1 ;
  22. }
  23. }
  24. if( ( mx - mn ) == ( cnt - 1 ) )
  25. cout << "YES" << endl ;
  26. else
  27. cout << "NO" << endl ;
  28. }
  29. return 0 ;
  30. }
  31.  
  32.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty