import sys
input = sys.stdin.readline
n = int(input())
lst = list(map(int,input().split()))
r_lst = lst[::-1] #감소하는 부분 수열을 구하기 위함 뒤집어 저장
increase = [1 for i in range(n)]
decrease = [1 for i in range(n)]
for i in range(n):
for j in range(i):
if lst[i] > lst[j]:
increase[i] = max(increase[i],increase[j]+1)
if r_lst[i] > r_lst[j]:
decrease[i] = max(decrease[i],decrease[j]+1)
result = [0 for i in range(n)]
for i in range(n):
result[i] = increase[i] + decrease[n-i-1] - 1
print(max(result))
'문제풀이 > 백준(Boj) 문제풀이' 카테고리의 다른 글
[백준][동적 계획법1] 10844. 쉬운 계단 수 (파이썬/Python) (0) | 2021.09.18 |
---|---|
[백준][동적 계획법1] 9251. LCS (파이썬/Python) (0) | 2021.09.17 |
[백준][동적 계획법1] 2565 . 전깃줄 (파이썬/Python) (0) | 2021.09.16 |
[백준][동적 계획법1] 11053. 가장 긴 증가하는 부분 수열LIS(파이썬/Python) (0) | 2021.09.15 |
[백준][동적 계획법1] 2156 . 포도주 시식(파이썬/Python) (0) | 2021.09.15 |