結果

問題 No.156 キャンディー・ボックス
ユーザー kazu116kazu116
提出日時 2019-05-10 17:00:46
言語 Swift
(5.10.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 1,725 ms
コンパイル使用メモリ 132,192 KB
実行使用メモリ 8,012 KB
最終ジャッジ日時 2023-08-20 12:23:59
合計ジャッジ時間 3,005 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
8,012 KB
testcase_01 AC 3 ms
7,924 KB
testcase_02 AC 3 ms
7,932 KB
testcase_03 AC 3 ms
7,860 KB
testcase_04 AC 3 ms
7,924 KB
testcase_05 AC 4 ms
7,864 KB
testcase_06 AC 5 ms
7,860 KB
testcase_07 AC 5 ms
7,928 KB
testcase_08 AC 4 ms
7,924 KB
testcase_09 AC 4 ms
7,928 KB
testcase_10 AC 4 ms
7,904 KB
testcase_11 AC 4 ms
7,836 KB
testcase_12 AC 5 ms
7,924 KB
testcase_13 AC 4 ms
7,924 KB
testcase_14 AC 3 ms
7,816 KB
testcase_15 AC 5 ms
7,756 KB
testcase_16 AC 4 ms
7,892 KB
testcase_17 AC 4 ms
7,896 KB
testcase_18 AC 4 ms
7,756 KB
testcase_19 AC 3 ms
7,900 KB
testcase_20 AC 3 ms
7,932 KB
testcase_21 AC 3 ms
7,812 KB
testcase_22 AC 3 ms
7,888 KB
testcase_23 AC 3 ms
7,868 KB
testcase_24 AC 3 ms
7,956 KB
testcase_25 AC 3 ms
7,868 KB
testcase_26 AC 3 ms
8,000 KB
testcase_27 AC 3 ms
7,824 KB
testcase_28 AC 3 ms
7,812 KB
testcase_29 AC 3 ms
7,860 KB
testcase_30 AC 9 ms
7,828 KB
testcase_31 AC 4 ms
7,744 KB
testcase_32 AC 35 ms
7,900 KB
testcase_33 AC 35 ms
7,928 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