結果

問題 No.1465 Archaea
コンテスト
ユーザー バカらっく
提出日時 2023-01-26 22:14:16
言語 Kotlin
(2.3.10)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 659 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,174 ms
コンパイル使用メモリ 446,864 KB
実行使用メモリ 89,468 KB
最終ジャッジ日時 2026-03-15 10:17:54
合計ジャッジ時間 16,016 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.LinkedList

fun main(args: Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val stetps = arrayOfNulls<Int>(n+1)
    val queue = LinkedList<Int>()
    queue.add(1)
    stetps[1] = 0
    while (queue.isNotEmpty()) {
        val cur = queue.pop()
        val nextStep = stetps[cur]!! + 1
        val nextList = listOf(cur*2, cur+3).filter { it <= n }
        for(next in nextList) {
            if(stetps[next] == null || stetps[next]!! > nextStep) {
                stetps[next] = nextStep
                queue.add(next)
            }
        }
    }
    println(if((stetps[n] ?: (k + 1)) > k) "NO" else "YES")
}
0