結果
| 問題 | 
                            No.156 キャンディー・ボックス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-10-10 13:38:08 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,357 bytes | 
| コンパイル時間 | 13,669 ms | 
| コンパイル使用メモリ | 402,636 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-21 06:45:59 | 
| 合計ジャッジ時間 | 15,435 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 26 WA * 4 | 
ソースコード
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}
fn main() {
    let mut number_of_empty_candy_box = 0;
    let line = getline();
    let params: Vec<_> = line.trim().split(' ').collect();
    let number_of_candy_box: usize = params[0].parse().unwrap();
    let number_of_pick_candy: usize = params[1].parse().unwrap();
    let line = getline();
    let params: Vec<_> = line.trim().split(' ').collect();
    let mut candy_boxes: Vec<i32> = Vec::new();
    for i in 0..number_of_candy_box {
        let number_of_candy: i32 = params[i].parse().unwrap();
        candy_boxes.push(number_of_candy);
    }
    for _ in 0..number_of_pick_candy {
        let mut min = 100000;
        let mut min_candy_box_index: usize = 0;
        for i in 0..number_of_candy_box {
            if candy_boxes[i] == 0 {
                continue;
            }
            if candy_boxes[i] <= min {
                min = candy_boxes[i];
                min_candy_box_index = i;
            }
        }
        if candy_boxes[min_candy_box_index] - 1 >= 0 {
            candy_boxes[min_candy_box_index] -= 1;
            if candy_boxes[min_candy_box_index] == 0 {
                number_of_empty_candy_box += 1;
            }
        }
    }
    println!("{}", number_of_empty_candy_box);
}