結果

問題 No.5 数字のブロック
コンテスト
ユーザー uchida_t
提出日時 2023-05-10 15:46:53
言語 Kotlin
(2.4.10 + ACL)
コンパイル:
kotlinc -cp /opt/aclib/ac_library.jar _filename_ -include-runtime -d main.jar
実行:
java -cp main.jar:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 176 ms / 5,000 ms
+ 526µs
コード長 487 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,318 ms
コンパイル使用メモリ 502,880 KB
実行使用メモリ 52,680 KB
最終ジャッジ日時 2026-09-30 12:42:55
合計ジャッジ時間 17,926 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

fun main(args: Array<String>) {
    var bigBox = readLine()!!.toInt()
    var numOfSmallBox = readLine()!!.toInt()
    var smallBoxes = readLine()!!.split(" ").map { it.toInt() }
    val sorted = smallBoxes.sorted()
    var boxList = mutableListOf<Int>()
    var total = 0
    
    for (i in 0 until numOfSmallBox) {
        total += sorted[i]
        if (total > bigBox) {
            break
        } else {
            boxList.add(sorted[i])
        }
    }
    println(boxList.size)
}
0