結果

問題 No.1868 Teleporting Cyanmond
ユーザー maguroflymagurofly
提出日時 2022-03-11 21:55:17
言語 Ruby
(3.3.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 11,232 KB
実行使用メモリ 23,656 KB
最終ジャッジ日時 2023-10-14 07:01:36
合計ジャッジ時間 4,884 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,080 KB
testcase_01 AC 76 ms
15,128 KB
testcase_02 AC 77 ms
15,284 KB
testcase_03 AC 133 ms
21,720 KB
testcase_04 AC 120 ms
20,228 KB
testcase_05 AC 83 ms
15,540 KB
testcase_06 AC 88 ms
16,028 KB
testcase_07 AC 110 ms
17,972 KB
testcase_08 AC 108 ms
16,968 KB
testcase_09 AC 103 ms
17,780 KB
testcase_10 AC 126 ms
21,032 KB
testcase_11 AC 79 ms
15,284 KB
testcase_12 AC 90 ms
16,616 KB
testcase_13 AC 112 ms
18,636 KB
testcase_14 AC 140 ms
22,208 KB
testcase_15 AC 118 ms
20,000 KB
testcase_16 AC 84 ms
15,748 KB
testcase_17 AC 88 ms
16,444 KB
testcase_18 AC 149 ms
23,460 KB
testcase_19 AC 155 ms
23,380 KB
testcase_20 AC 151 ms
23,580 KB
testcase_21 AC 152 ms
23,448 KB
testcase_22 AC 150 ms
23,344 KB
testcase_23 AC 150 ms
23,656 KB
testcase_24 AC 149 ms
23,576 KB
testcase_25 AC 151 ms
23,400 KB
testcase_26 AC 152 ms
23,368 KB
testcase_27 AC 152 ms
23,452 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
R = gets.split.map { _1.to_i - 1 }

first = [10**18] * N
R.each_with_index do |r, i|
    first[r] = [first[r], i].min
end
(0 ... N - 1).reverse_each do |i|
    first[i] = [first[i], first[i + 1]].min
end

ans = 0
right = N - 1
while right != 0
    right = first[right]
    ans += 1
end

puts ans
0