update gitignore and complete 11054.py
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,3 +7,6 @@ venv
|
|||||||
.venv
|
.venv
|
||||||
|
|
||||||
.ipynb_checkpoints
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
__init__.py
|
||||||
|
**/test_*.py
|
||||||
27
zeta_python/completed/11054.py
Normal file
27
zeta_python/completed/11054.py
Normal 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()))))
|
||||||
Reference in New Issue
Block a user