結果

問題 No.156 キャンディー・ボックス
ユーザー バカらっくバカらっく
提出日時 2019-09-05 03:36:28
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 317 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 16,030 ms
コンパイル使用メモリ 422,312 KB
実行使用メモリ 57,308 KB
最終ジャッジ日時 2023-08-29 01:37:05
合計ジャッジ時間 27,828 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 313 ms
56,724 KB
testcase_01 AC 310 ms
56,936 KB
testcase_02 AC 308 ms
56,768 KB
testcase_03 AC 316 ms
57,048 KB
testcase_04 AC 317 ms
57,052 KB
testcase_05 AC 314 ms
56,736 KB
testcase_06 AC 314 ms
56,796 KB
testcase_07 AC 312 ms
56,736 KB
testcase_08 AC 312 ms
56,656 KB
testcase_09 AC 312 ms
56,720 KB
testcase_10 AC 312 ms
56,804 KB
testcase_11 AC 310 ms
56,880 KB
testcase_12 AC 313 ms
56,884 KB
testcase_13 AC 314 ms
56,672 KB
testcase_14 AC 312 ms
57,172 KB
testcase_15 AC 314 ms
57,308 KB
testcase_16 AC 309 ms
56,732 KB
testcase_17 AC 308 ms
56,724 KB
testcase_18 AC 308 ms
56,736 KB
testcase_19 AC 316 ms
56,900 KB
testcase_20 AC 306 ms
57,280 KB
testcase_21 AC 309 ms
56,724 KB
testcase_22 AC 310 ms
56,940 KB
testcase_23 AC 308 ms
56,760 KB
testcase_24 AC 291 ms
52,660 KB
testcase_25 AC 291 ms
53,420 KB
testcase_26 AC 305 ms
56,748 KB
testcase_27 AC 308 ms
56,688 KB
testcase_28 AC 305 ms
56,796 KB
testcase_29 AC 305 ms
56,664 KB
testcase_30 AC 305 ms
56,804 KB
testcase_31 AC 308 ms
56,756 KB
testcase_32 AC 309 ms
56,768 KB
testcase_33 AC 309 ms
56,884 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:2:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:3:10: warning: variable 'n' is never used
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
         ^

ソースコード

diff #

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val list = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var cnt = 0
    var subTotal = 0
    list.forEach {
        if(subTotal < m) {
            subTotal = subTotal + it
            cnt++
            if(subTotal > m) {
                cnt--
            }
        }
    }
    println(cnt)
}
0