Skip to content

Instantly share code, notes, and snippets.

@Bandd-k
Created May 18, 2019 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bandd-k/9f2049e9655bd77a6e4869bb01feee3e to your computer and use it in GitHub Desktop.
Save Bandd-k/9f2049e9655bd77a6e4869bb01feee3e to your computer and use it in GitHub Desktop.
import sys
FIN = open('input.txt', 'r')
x = FIN.read().split()[:-1]
prev = -999
cur = 0
answer = 0
# max increase
for element in x:
if element > prev:
cur += 1
else:
answer = max(answer, cur)
cur = 1
prev = element
# max decrease
answer = max(answer, cur)
cur = 0
prev = sys.maxint
for element in x:
if element < prev:
cur += 1
else:
answer = max(answer, cur)
cur = 1
prev = element
answer = max(answer, cur)
print(answer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment