結果
| 問題 |
No.617 Nafmo、買い出しに行く
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-31 23:49:05 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 779 ms / 2,000 ms |
| コード長 | 668 bytes |
| コンパイル時間 | 12,693 ms |
| コンパイル使用メモリ | 451,076 KB |
| 実行使用メモリ | 82,956 KB |
| 最終ジャッジ日時 | 2024-11-20 15:17:47 |
| 合計ジャッジ時間 | 25,861 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
コンパイルメッセージ
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] }
^
ソースコード
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)
}