結果

問題 No.1465 Archaea
ユーザー バカらっくバカらっく
提出日時 2023-01-26 22:14:16
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 436 ms / 2,000 ms
コード長 659 bytes
コンパイル時間 14,209 ms
コンパイル使用メモリ 423,924 KB
実行使用メモリ 60,456 KB
最終ジャッジ日時 2023-09-09 20:34:44
合計ジャッジ時間 24,483 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 303 ms
57,048 KB
testcase_01 AC 297 ms
56,852 KB
testcase_02 AC 306 ms
56,964 KB
testcase_03 AC 303 ms
56,976 KB
testcase_04 AC 300 ms
57,020 KB
testcase_05 AC 305 ms
56,876 KB
testcase_06 AC 305 ms
59,136 KB
testcase_07 AC 383 ms
58,156 KB
testcase_08 AC 303 ms
57,372 KB
testcase_09 AC 414 ms
58,772 KB
testcase_10 AC 300 ms
56,944 KB
testcase_11 AC 398 ms
59,400 KB
testcase_12 AC 313 ms
56,880 KB
testcase_13 AC 436 ms
60,076 KB
testcase_14 AC 424 ms
59,480 KB
testcase_15 AC 317 ms
56,952 KB
testcase_16 AC 308 ms
57,076 KB
testcase_17 AC 422 ms
59,540 KB
testcase_18 AC 326 ms
56,996 KB
testcase_19 AC 420 ms
59,532 KB
testcase_20 AC 411 ms
58,780 KB
testcase_21 AC 434 ms
60,456 KB
testcase_22 AC 434 ms
60,148 KB
testcase_23 AC 296 ms
56,988 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

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