結果

問題 No.1736 Princess vs. Dragoness
ユーザー Masaki KitaguchiMasaki Kitaguchi
提出日時 2022-01-07 21:49:50
言語 Rust
(1.77.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,450 bytes
コンパイル時間 2,638 ms
コンパイル使用メモリ 153,392 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 18:36:10
合計ジャッジ時間 2,383 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 14 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 5 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 5 ms
5,376 KB
testcase_19 AC 6 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 11 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 3 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut buf = String::new();
    let mut input = {
        use std::io::Read;
        std::io::stdin().read_to_string(&mut buf).unwrap();
        buf.split_whitespace()
    };

    let n: usize = input.next().unwrap().parse().unwrap();
    let a: usize = input.next().unwrap().parse().unwrap();
    let b: usize = input.next().unwrap().parse().unwrap();
    let x: i64 = input.next().unwrap().parse().unwrap();
    let y: i64 = input.next().unwrap().parse().unwrap();
    let mut h: Vec<i64> = (0..n)
        .map(|_| input.next().unwrap().parse().unwrap())
        .collect();

    for _ in 0..a {
        let i = max_hp_index(&h);
        h[i] -= x;
    }

    for _ in 0..b {
        let mut p = y;
        for i in 0..n {
            if h[i] > 0 {
                if h[i] < p {
                    p -= h[i];
                    h[i] = 0;
                } else {
                    h[i] -= p;
                    p = 0;
                }
            }
            if p == 0 {
                break;
            }
        }
    }

    let output = if h
        .iter()
        .fold(true, |acc, &hp| if hp > 0 { false } else { acc })
    {
        "Yes"
    } else {
        "No"
    };

    println!("{}", output);
}

fn max_hp_index(h: &Vec<i64>) -> usize {
    let mut index = 0;
    let mut hp = h[0];
    for i in 0..h.len() {
        if h[i] > hp {
            index = i;
            hp = h[i];
        }
    }
    index
}
0