結果

問題 No.1868 Teleporting Cyanmond
ユーザー shobonvipshobonvip
提出日時 2022-03-11 21:29:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 93,280 KB
最終ジャッジ日時 2023-10-14 06:16:45
合計ジャッジ時間 5,205 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,460 KB
testcase_01 AC 95 ms
71,740 KB
testcase_02 AC 95 ms
71,788 KB
testcase_03 AC 132 ms
90,956 KB
testcase_04 AC 118 ms
86,452 KB
testcase_05 AC 107 ms
77,680 KB
testcase_06 AC 113 ms
77,944 KB
testcase_07 AC 120 ms
82,584 KB
testcase_08 AC 113 ms
79,876 KB
testcase_09 AC 118 ms
81,732 KB
testcase_10 AC 132 ms
89,384 KB
testcase_11 AC 107 ms
77,884 KB
testcase_12 AC 113 ms
79,132 KB
testcase_13 AC 122 ms
82,752 KB
testcase_14 AC 136 ms
90,968 KB
testcase_15 AC 125 ms
86,288 KB
testcase_16 AC 109 ms
77,912 KB
testcase_17 AC 119 ms
78,712 KB
testcase_18 AC 141 ms
93,032 KB
testcase_19 AC 144 ms
92,784 KB
testcase_20 AC 136 ms
93,280 KB
testcase_21 AC 143 ms
93,188 KB
testcase_22 AC 139 ms
93,156 KB
testcase_23 AC 149 ms
93,068 KB
testcase_24 AC 145 ms
93,160 KB
testcase_25 AC 144 ms
93,164 KB
testcase_26 AC 148 ms
93,160 KB
testcase_27 AC 145 ms
93,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n = int(input())
r = list(map(int,input().split()))

tansaku = [0] * n
dp = [0] * n

mada = deque([0])
tmp = 0

while mada:
	i = mada.popleft()
	if i < n-1:
		for j in range(max(tmp, i+1), r[i]):
			if tansaku[j] == 0:
				tansaku[j] = 1
				mada.append(j)
				dp[j] = dp[i] + 1
		tmp = max(tmp, r[i])

print(dp[n-1])
0