結果

問題 No.115 遠足のおやつ
ユーザー バカらっくバカらっく
提出日時 2019-10-01 08:17:28
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 817 ms / 5,000 ms
コード長 1,215 bytes
コンパイル時間 15,388 ms
コンパイル使用メモリ 423,752 KB
実行使用メモリ 86,456 KB
最終ジャッジ日時 2023-08-31 00:56:43
合計ジャッジ時間 32,895 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 288 ms
53,032 KB
testcase_01 AC 301 ms
53,660 KB
testcase_02 AC 312 ms
53,860 KB
testcase_03 AC 285 ms
53,036 KB
testcase_04 AC 442 ms
62,144 KB
testcase_05 AC 288 ms
53,152 KB
testcase_06 AC 293 ms
53,036 KB
testcase_07 AC 306 ms
53,644 KB
testcase_08 AC 288 ms
53,044 KB
testcase_09 AC 294 ms
53,292 KB
testcase_10 AC 293 ms
53,008 KB
testcase_11 AC 292 ms
53,112 KB
testcase_12 AC 296 ms
53,068 KB
testcase_13 AC 289 ms
53,052 KB
testcase_14 AC 311 ms
53,884 KB
testcase_15 AC 430 ms
61,864 KB
testcase_16 AC 414 ms
62,008 KB
testcase_17 AC 295 ms
53,124 KB
testcase_18 AC 304 ms
53,760 KB
testcase_19 AC 298 ms
53,036 KB
testcase_20 AC 299 ms
53,136 KB
testcase_21 AC 295 ms
53,188 KB
testcase_22 AC 433 ms
61,996 KB
testcase_23 AC 320 ms
53,860 KB
testcase_24 AC 439 ms
61,992 KB
testcase_25 AC 300 ms
53,136 KB
testcase_26 AC 308 ms
53,672 KB
testcase_27 AC 316 ms
53,920 KB
testcase_28 AC 321 ms
53,676 KB
testcase_29 AC 313 ms
53,708 KB
testcase_30 AC 434 ms
62,036 KB
testcase_31 AC 405 ms
61,404 KB
testcase_32 AC 438 ms
61,912 KB
testcase_33 AC 287 ms
53,060 KB
testcase_34 AC 464 ms
62,228 KB
testcase_35 AC 415 ms
61,896 KB
testcase_36 AC 445 ms
63,316 KB
testcase_37 AC 434 ms
62,024 KB
testcase_38 AC 817 ms
86,404 KB
testcase_39 AC 802 ms
86,456 KB
testcase_40 AC 291 ms
53,400 KB
testcase_41 AC 287 ms
53,016 KB
testcase_42 AC 290 ms
53,020 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
         ^

ソースコード

diff #

fun main(arr:Array<String>) {
    val(n,d,k) = readLine()!!.split(" ").map { it.toInt() }
    itemCount = n
    val ans = getAns(1, d, k)
    println(ans.joinToString(" "))
}

var itemCount = 0
val dic = mutableMapOf<Int, MutableMap<Int, MutableMap<Int, List<Int>>>>()

fun getAns(index:Int, remain:Int, remainCount:Int):MutableList<Int> {
    if(remain == 0) {
        if(remainCount == 0) {
            return mutableListOf()
        } else {
            return mutableListOf(-1)
        }
    }
    if(remainCount <= 0) {
        return mutableListOf(-1)
    }
    if(index > itemCount) {
        return mutableListOf(-1)
    }
    if(remain < 0) {
        return mutableListOf(-1)
    }

    dic[index]?: run { dic[index] = mutableMapOf() }
    dic[index]!![remain]?: run { dic[index]!![remain] = mutableMapOf() }
    dic[index]!![remain]!![remainCount]?.let { return it.toMutableList() }

    var ret = getAns(index + 1, remain - index, remainCount - 1)
    if(ret.isEmpty() || ret[0] != -1) {
        ret = ret.map { it }.toMutableList()
        ret.add(0, index)
    } else {
        ret = getAns(index + 1, remain, remainCount)
    }
    dic[index]!![remain]!![remainCount] = ret.map { it }
    return ret
}
0