Advertisement
PikMike

Untitled

Dec 30th, 2015
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. n = int(input())
  2. a = [int(x) for x in input().split()]
  3. b = [2 for x in range(n)]
  4. for i in range(1, n - 1):
  5.   if (a[i] < a[i - 1]) and (a[i] < a[i + 1]):
  6.     b[i] = b[i - 1] + 1
  7.   elif (a[i] > a[i - 1]) and (a[i] > a[i + 1]):
  8.     b[i] = b[i - 1] + 1
  9. print(min(n, max(b)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement