Advertisement
Ankit_132

B

Feb 14th, 2024
972
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int t;
  6.     cin>>t;
  7.    
  8.     while(t--){
  9.         int n;
  10.         cin>>n;
  11.        
  12.         vector<int> a(n);
  13.         for(auto &e: a)
  14.             cin>>e;
  15.        
  16.         if(n==2 && a[1]<a[0])
  17.             cout<<"NO\n";
  18.         else if(n==3 && (a[1]<min(a[0], a[2]) || a[1]>max(a[0], a[2])))
  19.             cout<<"NO\n";
  20.         else
  21.             cout<<"YES\n";
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement