結果

問題 No.1868 Teleporting Cyanmond
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-03-11 21:30:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 258 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 92,308 KB
最終ジャッジ日時 2023-10-14 06:18:45
合計ジャッジ時間 6,695 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,268 KB
testcase_01 AC 76 ms
71,160 KB
testcase_02 AC 76 ms
71,164 KB
testcase_03 AC 235 ms
90,068 KB
testcase_04 AC 191 ms
85,900 KB
testcase_05 AC 130 ms
77,944 KB
testcase_06 AC 159 ms
78,724 KB
testcase_07 AC 180 ms
82,812 KB
testcase_08 AC 168 ms
80,096 KB
testcase_09 AC 185 ms
81,984 KB
testcase_10 AC 231 ms
88,604 KB
testcase_11 AC 107 ms
77,808 KB
testcase_12 AC 163 ms
79,956 KB
testcase_13 AC 210 ms
82,908 KB
testcase_14 AC 228 ms
90,012 KB
testcase_15 AC 221 ms
85,084 KB
testcase_16 AC 177 ms
79,008 KB
testcase_17 AC 186 ms
79,460 KB
testcase_18 AC 228 ms
91,708 KB
testcase_19 AC 220 ms
91,676 KB
testcase_20 AC 258 ms
91,836 KB
testcase_21 AC 248 ms
91,700 KB
testcase_22 AC 243 ms
91,440 KB
testcase_23 AC 157 ms
91,864 KB
testcase_24 AC 200 ms
92,028 KB
testcase_25 AC 172 ms
92,092 KB
testcase_26 AC 194 ms
92,308 KB
testcase_27 AC 190 ms
91,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

"""

import sys
from sys import stdin
import heapq

N = int(stdin.readline())

R = list(map(int,stdin.readline().split()))
for i in range(N-1):
    R[i] -= 1

dp = [float("inf")] * N

q = []
dp[0] = 0
heapq.heappush( q,(0,R[0]) )

for i in range(1,N):

    while q[0][1] < i:
        heapq.heappop(q)

    dp[i] = q[0][0] + 1
    if i != N-1:
        heapq.heappush(q , (dp[i],R[i])  )

print (dp[-1])
#print (dp)
0