Advertisement
AquaBlitz11

TASK_052 - AquaBlitz11's Solution

Jan 7th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     scanf("%d", &n);
  9.  
  10.     bool down = false, fail = false;
  11.     int v = 0;
  12.     for (int i = 0; i < n && !fail; ++i) {
  13.         int x;
  14.         scanf("%d", &x);
  15.         if (x == v) {
  16.             fail = true;
  17.         } else if (x > v) {
  18.             if (down)
  19.                 fail = true;
  20.         } else { // x < v
  21.             down = true;
  22.         }
  23.         v = x;
  24.     }
  25.     if (fail)
  26.         printf("No\n");
  27.     else
  28.         printf("Yes\n");
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement