-문제: https://www.acmicpc.net/problem/11722

이거는 가장 긴 증가하는 수열을 n-1 부터 진행하면 된다 

풀이는 거의 똑같지만, 반복문 범위가 n-1부터 시작해 -1씩 진행하면 된다 

-정답풀이:

n=int(input())
data=list(map(int,input().split()))
dp=[0]*n
for i in range(n-1,-1,-1):#n-1에서 0까지 -1씩 진행
    for j in range(n-1,i-1,-1): #n-1부터 i까지 -1씩 진행
        if data[i]>data[j] and dp[i]<dp[j]:
            dp[i]=dp[j]
    dp[i]+=1
print(max(dp))

+ Recent posts