BOJ - 11060 - 점프
Updated:
import sys
def solution():
N = int(input())
step = list(map(int, sys.stdin.readline().split(' ')))
dp = [1000001 for _ in range(N)]
dp[0] = 1
for i in range(0, N):
j = step[i]
for j in range(i+1, i + j + 1):
if j < N:
dp[j] = min(dp[j], dp[i] + 1)
if dp[len(dp)-1] > 1000000: print(-1)
else : print(dp[len(dp)-1]-1)
solution()
https://www.acmicpc.net/problem/11060
Leave a comment