update gitignore and complete 11054.py

This commit is contained in:
2021-03-03 02:56:42 +09:00
parent a225d7c91e
commit 2b4142038e
2 changed files with 31 additions and 1 deletions

5
.gitignore vendored
View File

@@ -6,4 +6,7 @@ out/
venv
.venv
.ipynb_checkpoints
.ipynb_checkpoints
__init__.py
**/test_*.py

View File

@@ -0,0 +1,27 @@
def solve(N: int, A: list):
T = [[0, 0] for _ in range(N)]
T[0][0] = 1 # 상승부
T[0][1] = 1 # 하강부
for i in range(1, N): # mainloop
t = []
for j in range(i):
if A[j] < A[i]:
t.append(T[j][0] + 1)
else:
t.append(1)
T[i][0] = max(t)
t = []
for j in range(i):
if A[j] > A[i]:
t.append(T[j][0] + 1)
t.append(T[j][1] + 1)
else:
t.append(1)
T[i][1] = max(t)
return max(max(T, key=lambda x: max(x)))
if __name__ == '__main__':
print(solve(int(input()), list(map(int, input().split()))))