From 2b4142038ed3003500e885b81e9a0ed8252bf676 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Wed, 3 Mar 2021 02:56:42 +0900 Subject: [PATCH] update gitignore and complete 11054.py --- .gitignore | 5 ++++- zeta_python/completed/11054.py | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 zeta_python/completed/11054.py diff --git a/.gitignore b/.gitignore index 67e8275..1ffadeb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ out/ venv .venv -.ipynb_checkpoints \ No newline at end of file +.ipynb_checkpoints + +__init__.py +**/test_*.py \ No newline at end of file diff --git a/zeta_python/completed/11054.py b/zeta_python/completed/11054.py new file mode 100644 index 0000000..0816373 --- /dev/null +++ b/zeta_python/completed/11054.py @@ -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()))))