fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. ios_base::sync_with_stdio(false);
  7. cin.tie(NULL);
  8.  
  9. long n;
  10. long max;
  11. cin>>n;
  12. long A[n];
  13. for(long i=0;i<n;i++){
  14. cin>>A[i];
  15. }
  16. max=A[0];
  17. for(long i=0,j=n-1;i<n/2;i++,j--){
  18. if(A[i]>=max){
  19. if(A[i]<=A[j])
  20. max=A[j];
  21. else{
  22. cout<<"no";
  23. return 0;
  24. }
  25. }
  26. else {
  27. cout<<"no";
  28. return 0;
  29. }
  30.  
  31. }
  32. cout<<"yes";
  33. return 0;
  34. }
Success #stdin #stdout 0s 4348KB
stdin
7
-2 -2 14 20 18 12 -1
stdout
no