[DP] 11060번 - 점프 점프 (3일차)

bob.sort·2021년 6월 13일
0
post-thumbnail
post-custom-banner
n = int(input())
maze = list(map(int, input().split()))

dp = [-1] * n

dp[0] = 0

for i in range(n):
    
    for j in range(1,maze[i]+1):
        
        if(i+j >= n):
            break

        elif(dp[i] != -1 and dp[i+j] == -1):
            dp[i+j] = dp[i]+1

        elif(dp[i] != -1 and dp[i+j] != -1):
            dp[i+j] = min(dp[i+j], dp[i]+1)
    

print(dp[-1])
profile
Interest in Computer Graphics and Computer Vision

0개의 댓글