結果

問題 No.1868 Teleporting Cyanmond
ユーザー LyricalMaestro
提出日時 2025-06-15 22:21:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 82,692 KB
実行使用メモリ 91,168 KB
最終ジャッジ日時 2025-06-15 22:21:24
合計ジャッジ時間 6,741 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/1868

import heapq

MAX_INT = 10 ** 18

def main():
    N = int(input())
    R = list(map(int, input().split()))


    dp = [MAX_INT] * N

    queue = []
    heapq.heappush(queue,(0, 0))

    for x in range(N):

        while len(queue) > 0 and queue[0][-1] < x:
            heapq.heappop(queue)
        
        v = queue[0][0]
        dp[x] = v

        if x < N - 1:
            heapq.heappush(queue, (v + 1, R[x] - 1))

    print(dp[-1])



    




if __name__ == "__main__":
    main()
0