Created
November 21, 2022 17:44
-
-
Save qjatn0120/42359fd8a077eaa259f717ae3c934287 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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