結果

問題 No.1465 Archaea
ユーザー rodearodea
提出日時 2021-04-09 16:36:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 80,412 KB
最終ジャッジ日時 2023-09-07 04:58:43
合計ジャッジ時間 5,247 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,044 KB
testcase_01 AC 77 ms
71,252 KB
testcase_02 AC 88 ms
75,684 KB
testcase_03 AC 75 ms
71,364 KB
testcase_04 AC 75 ms
71,024 KB
testcase_05 AC 76 ms
71,388 KB
testcase_06 AC 75 ms
71,420 KB
testcase_07 AC 150 ms
78,064 KB
testcase_08 AC 76 ms
71,500 KB
testcase_09 AC 153 ms
78,452 KB
testcase_10 AC 74 ms
71,260 KB
testcase_11 AC 147 ms
78,336 KB
testcase_12 AC 98 ms
76,392 KB
testcase_13 AC 177 ms
79,520 KB
testcase_14 AC 145 ms
78,164 KB
testcase_15 AC 89 ms
75,804 KB
testcase_16 AC 96 ms
76,496 KB
testcase_17 AC 172 ms
79,628 KB
testcase_18 AC 133 ms
78,104 KB
testcase_19 AC 154 ms
78,484 KB
testcase_20 AC 163 ms
78,620 KB
testcase_21 AC 184 ms
80,412 KB
testcase_22 AC 187 ms
80,108 KB
testcase_23 AC 75 ms
71,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n, k = map(int, input().split())

dp = [10 ** 9] * (n + 1)
dp[1] = 0
que = [1]
heapq.heapify(que)
while len(que):
    cur = heapq.heappop(que)
    if cur * 2 <= n and dp[cur] + 1 < dp[cur * 2]:
        dp[cur * 2] = dp[cur] + 1
        heapq.heappush(que, cur * 2)
    if cur + 3 <= n and dp[cur] + 1 < dp[cur + 3]:
        dp[cur + 3] = dp[cur] + 1
        heapq.heappush(que, cur + 3)

print("YES") if dp[n] <= k else print("NO")
0