본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 5566번 주사위 게임

by 현장 2025. 2. 26.

-Code

n, m = map(int, input().split())
order_list = [int(input()) for _ in range(n)]
position = 1

for i in range(1, m + 1):
    position += int(input())

    if position >= n:
        print(i)
        break
    position += order_list[position - 1]
    if position >= n:
        print(i)
        break