Skip to content

Instantly share code, notes, and snippets.

@qjatn0120
Created November 21, 2022 17:44
Show Gist options
  • Save qjatn0120/42359fd8a077eaa259f717ae3c934287 to your computer and use it in GitHub Desktop.
Save qjatn0120/42359fd8a077eaa259f717ae3c934287 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
const int MX = 2e5 + 5;
int t, n, arr[MX];
int main(){
cin.tie(nullptr), ios::sync_with_stdio(false);
cin >> t;
while(t--){
cin >> n;
for(int i = 0; i < n; i++) cin >> arr[i];
int idx = min_element(arr, arr + n) - arr;
bool ans = true;
for(int i = idx - 1; i >= 0; i--){
if(arr[i] < arr[i + 1]) ans = false;
}
for(int i = idx + 1; i < n; i++){
if(arr[i] < arr[i - 1]) ans = false;
}
cout << (ans ? "YES\n" : "NO\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment