Advertisement
AquaBlitz11

TASK_052 - ChimengSoso's Solution

Jan 7th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int a[123];
  4.  
  5. int main() {
  6.     int n;
  7.     scanf("%d", &n);
  8.  
  9.     for (int i = 1; i <= n; ++i) {
  10.         scanf("%d", &a[i]);
  11.     }
  12.  
  13.     int cntPeak = 0;
  14.     for (int i = 1; i <= n; ++i) {
  15.         int l = a[i-1], m = a[i], r = a[i+1];
  16.         if (l == m) return printf("No\n"), 0;
  17.         if (l < m and m > r)
  18.             ++cntPeak;
  19.     }
  20.  
  21.     printf("%s\n", cntPeak == 1 ? "Yes" : "No");
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement