結果
| 問題 | No.156 キャンディー・ボックス |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-10 17:00:46 |
| 言語 | Swift (6.2.4) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 381 bytes |
| 記録 | |
| コンパイル時間 | 1,307 ms |
| コンパイル使用メモリ | 153,244 KB |
| 実行使用メモリ | 9,984 KB |
| 最終ジャッジ日時 | 2026-05-24 05:34:08 |
| 合計ジャッジ時間 | 2,796 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
コンパイルメッセージ
Main.swift:7:5: warning: immutable value 'i' was never used; consider replacing with '_' or removing it [#no-usage]
5 |
6 | var box:Int = 0
7 | for i in 0 ..< a[1] {
| `- warning: immutable value 'i' was never used; consider replacing with '_' or removing it [#no-usage]
8 | if b[box] == 0 {
9 | box += 1
ソースコード
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)