Created
May 18, 2019 02:28
-
-
Save Bandd-k/9f2049e9655bd77a6e4869bb01feee3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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