結果

問題 No.156 キャンディー・ボックス
ユーザー kazu116kazu116
提出日時 2019-05-10 17:00:46
言語 Swift
(5.10.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 1,644 ms
コンパイル使用メモリ 135,668 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-05-07 19:04:31
合計ジャッジ時間 2,604 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
9,216 KB
testcase_01 AC 8 ms
9,216 KB
testcase_02 AC 8 ms
9,216 KB
testcase_03 AC 7 ms
9,216 KB
testcase_04 AC 8 ms
9,216 KB
testcase_05 AC 9 ms
9,344 KB
testcase_06 AC 10 ms
9,344 KB
testcase_07 AC 9 ms
9,344 KB
testcase_08 AC 8 ms
9,344 KB
testcase_09 AC 8 ms
9,216 KB
testcase_10 AC 9 ms
9,344 KB
testcase_11 AC 8 ms
9,216 KB
testcase_12 AC 9 ms
9,216 KB
testcase_13 AC 9 ms
9,344 KB
testcase_14 AC 9 ms
9,344 KB
testcase_15 AC 10 ms
9,216 KB
testcase_16 AC 9 ms
9,344 KB
testcase_17 AC 9 ms
9,216 KB
testcase_18 AC 8 ms
9,344 KB
testcase_19 AC 8 ms
9,344 KB
testcase_20 AC 8 ms
9,088 KB
testcase_21 AC 8 ms
9,216 KB
testcase_22 AC 8 ms
9,344 KB
testcase_23 AC 8 ms
9,344 KB
testcase_24 AC 8 ms
9,344 KB
testcase_25 AC 8 ms
9,216 KB
testcase_26 AC 7 ms
9,344 KB
testcase_27 AC 7 ms
9,216 KB
testcase_28 AC 8 ms
9,216 KB
testcase_29 AC 8 ms
9,216 KB
testcase_30 AC 14 ms
9,216 KB
testcase_31 AC 8 ms
9,344 KB
testcase_32 AC 38 ms
9,216 KB
testcase_33 AC 39 ms
9,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.swift:7:5: warning: immutable value 'i' was never used; consider replacing with '_' or removing it
for i in 0 ..< a[1] {
    ^
    _

ソースコード

diff #

let a:[Int] = readLine()!.split(separator: " ").map{Int($0)!}
var b:[Int] = readLine()!.split(separator: " ").map{Int($0)!}

b.sort{$0 < $1}

var box:Int = 0
for i in 0 ..< a[1] {
    if b[box] == 0 {
        box += 1
        if box > a[0] {
            break
        }
    }
    b[box] -= 1
}

box = 0
for i in 0 ..< a[0] {
    if b[i] == 0 {
        box += 1
    }
}

print(box)
0