結果

問題 No.5 数字のブロック
ユーザー karayuukarayuu
提出日時 2018-12-09 16:43:07
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 632 bytes
コンパイル時間 13,116 ms
コンパイル使用メモリ 415,616 KB
実行使用メモリ 58,652 KB
最終ジャッジ日時 2023-08-13 01:04:36
合計ジャッジ時間 27,511 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 310 ms
57,160 KB
testcase_02 WA -
testcase_03 AC 403 ms
57,456 KB
testcase_04 AC 372 ms
57,244 KB
testcase_05 AC 406 ms
57,348 KB
testcase_06 AC 381 ms
57,288 KB
testcase_07 AC 372 ms
57,260 KB
testcase_08 AC 397 ms
58,652 KB
testcase_09 AC 352 ms
57,356 KB
testcase_10 AC 414 ms
57,304 KB
testcase_11 AC 368 ms
57,480 KB
testcase_12 AC 411 ms
57,564 KB
testcase_13 AC 403 ms
57,316 KB
testcase_14 AC 320 ms
57,004 KB
testcase_15 AC 323 ms
57,036 KB
testcase_16 AC 414 ms
57,212 KB
testcase_17 AC 417 ms
57,292 KB
testcase_18 AC 418 ms
57,204 KB
testcase_19 AC 420 ms
57,432 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 314 ms
56,840 KB
testcase_24 AC 322 ms
57,080 KB
testcase_25 AC 332 ms
57,084 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 365 ms
57,164 KB
testcase_30 AC 354 ms
57,216 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:4:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:5:13: warning: variable 'n' is never used
    val (l, n) = (0..1).map { readLine()!!.toInt() }
            ^

ソースコード

diff #

/**
 * Created by karayuu on 2018/12/09
 */
fun main(args: Array<String>) {
    val (l, n) = (0..1).map { readLine()!!.toInt() }
    val boxes = readLine()!!.split(" ").map { it.toInt() }.sorted()

    /*
     * 最大何個入りますか?なので、小さいほうから入れていったほうが多く入る。
     * 小さい順にソートして、小さいほうから入れていく。
     */

    var sum = 0
    for ((count, i) in boxes.withIndex()) {
        if (sum > l) {
            println(count - 1) //Listは0オリジンなので1引くのを忘れない
            return
        }
        sum += i
    }
}
0