結果

問題 No.617 Nafmo、買い出しに行く
ユーザー Pump0129Pump0129
提出日時 2018-03-31 23:49:05
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 766 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 12,117 ms
コンパイル使用メモリ 432,324 KB
実行使用メモリ 86,760 KB
最終ジャッジ日時 2024-04-30 17:59:27
合計ジャッジ時間 25,251 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 339 ms
57,444 KB
testcase_01 AC 331 ms
57,308 KB
testcase_02 AC 366 ms
57,816 KB
testcase_03 AC 413 ms
68,180 KB
testcase_04 AC 331 ms
57,176 KB
testcase_05 AC 433 ms
78,288 KB
testcase_06 AC 750 ms
86,720 KB
testcase_07 AC 750 ms
86,512 KB
testcase_08 AC 327 ms
57,252 KB
testcase_09 AC 332 ms
57,284 KB
testcase_10 AC 755 ms
86,744 KB
testcase_11 AC 744 ms
86,676 KB
testcase_12 AC 754 ms
86,724 KB
testcase_13 AC 762 ms
86,604 KB
testcase_14 AC 766 ms
86,760 KB
testcase_15 AC 737 ms
86,624 KB
testcase_16 AC 744 ms
86,604 KB
testcase_17 AC 745 ms
86,572 KB
testcase_18 AC 330 ms
57,304 KB
testcase_19 AC 331 ms
57,164 KB
testcase_20 AC 327 ms
57,272 KB
testcase_21 AC 330 ms
57,184 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:5:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:20:26: warning: 'sumBy((T) -> Int): Int' is deprecated. Use sumOf instead.
                        .sumBy { numList[it] }
                         ^

ソースコード

diff #

package net.ipipip0129.kotlin.yukicoder

import kotlin.math.max

fun main(args: Array<String>) {
    val data = readLine()!!.split(" ")
    val count = data[0].toInt()
    val maxNum = data[1].toInt()

    val numList = ArrayList<Int>()

    for (i in (0 until count)) numList.add(readLine()!!.toInt())

    var ans = 0
    (0 until 1.shl(count))
            .asSequence()
            .map { j ->
                (0 until count)
                        .filter { j.shr(it) % 2 == 1 }
                        .sumBy { numList[it] }
            }
            .filter { it <= maxNum }
            .forEach { ans = max(ans, it) }
    println(ans)
}
0