結果

問題 No.1868 Teleporting Cyanmond
ユーザー lloyzlloyz
提出日時 2022-03-11 21:39:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 306 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 90,972 KB
最終ジャッジ日時 2023-10-14 06:35:18
合計ジャッジ時間 4,493 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,088 KB
testcase_01 AC 77 ms
71,056 KB
testcase_02 AC 77 ms
71,228 KB
testcase_03 AC 178 ms
88,708 KB
testcase_04 AC 92 ms
84,308 KB
testcase_05 AC 83 ms
76,276 KB
testcase_06 AC 83 ms
76,104 KB
testcase_07 AC 89 ms
81,304 KB
testcase_08 AC 86 ms
78,468 KB
testcase_09 AC 89 ms
80,224 KB
testcase_10 AC 98 ms
87,328 KB
testcase_11 AC 82 ms
76,072 KB
testcase_12 AC 84 ms
77,268 KB
testcase_13 AC 88 ms
81,188 KB
testcase_14 AC 100 ms
89,116 KB
testcase_15 AC 96 ms
84,436 KB
testcase_16 AC 85 ms
76,316 KB
testcase_17 AC 86 ms
76,860 KB
testcase_18 AC 108 ms
90,772 KB
testcase_19 AC 103 ms
90,920 KB
testcase_20 AC 103 ms
90,920 KB
testcase_21 AC 103 ms
90,900 KB
testcase_22 AC 103 ms
90,668 KB
testcase_23 AC 104 ms
90,816 KB
testcase_24 AC 105 ms
90,972 KB
testcase_25 AC 103 ms
90,872 KB
testcase_26 AC 105 ms
90,972 KB
testcase_27 AC 105 ms
90,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

M = [0 for _ in range(n - 1)]
idx = 1
max_n = 1
for i in range(n - 1):
    if R[i] > max_n:
        idx = i + 1
        max_n = R[i]
    M[i] = idx

ans = 1
idx = 0
while R[idx] != n:
    nidx = M[R[idx] - 1] - 1
    idx = nidx
    ans += 1
print(ans)
0