結果

問題 No.1465 Archaea
ユーザー maguroflymagurofly
提出日時 2021-04-02 21:49:50
言語 Ruby
(3.2.2)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 11,536 KB
実行使用メモリ 16,928 KB
最終ジャッジ日時 2023-08-25 16:12:23
合計ジャッジ時間 3,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
15,220 KB
testcase_01 AC 66 ms
15,152 KB
testcase_02 AC 66 ms
15,044 KB
testcase_03 AC 66 ms
15,212 KB
testcase_04 AC 67 ms
15,080 KB
testcase_05 AC 66 ms
15,044 KB
testcase_06 AC 66 ms
15,120 KB
testcase_07 AC 81 ms
15,800 KB
testcase_08 AC 70 ms
15,152 KB
testcase_09 AC 90 ms
16,000 KB
testcase_10 AC 70 ms
15,184 KB
testcase_11 AC 87 ms
15,812 KB
testcase_12 AC 72 ms
15,020 KB
testcase_13 AC 110 ms
16,524 KB
testcase_14 AC 88 ms
16,060 KB
testcase_15 AC 71 ms
15,120 KB
testcase_16 AC 75 ms
15,072 KB
testcase_17 AC 113 ms
16,612 KB
testcase_18 AC 70 ms
15,120 KB
testcase_19 AC 85 ms
16,116 KB
testcase_20 AC 98 ms
16,368 KB
testcase_21 AC 118 ms
16,928 KB
testcase_22 AC 119 ms
16,896 KB
testcase_23 AC 66 ms
15,124 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.map(&:to_i)
dist = [nil, 0]
queue = [1]
until queue.empty?
    x = queue.shift
    d = dist[x]
    [x * 2, x + 3].each do |y|
        if y <= N and (!dist[y] or dist[y] > d + 1)
            dist[y] = d + 1
            queue << y
        end
    end
end

if dist[N] and dist[N] <= K
    puts "YES"
else
    puts "NO"
end
0