結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
|
提出日時 | 2021-06-16 13:56:09 |
言語 | Swift (6.0.3) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 332 bytes |
コンパイル時間 | 17,752 ms |
コンパイル使用メモリ | 135,576 KB |
実行使用メモリ | 9,344 KB |
最終ジャッジ日時 | 2024-12-30 11:58:20 |
合計ジャッジ時間 | 14,917 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
let inpA = readLine()!.split(separator: " ").map{Int($0)!} let inpB = readLine()! var candee = inpA[1] var boxs = inpB.split(separator: " ").map{Int($0)!}.sorted() var counter = 0 while candee > 0{ candee -= boxs.removeFirst() counter += 1 if candee < 0{ counter -= 1 candee = 0 } } print(counter)