結果

問題 No.1736 Princess vs. Dragoness
ユーザー seinyanseinyan
提出日時 2021-11-13 09:45:03
言語 Rust
(1.77.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,030 bytes
コンパイル時間 4,422 ms
コンパイル使用メモリ 130,124 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-17 22:02:13
合計ジャッジ時間 5,223 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

fn main() {
    let v1: Vec<i64> = input_line();
    let (_n, mut a, b, x, y) = (v1[0] as usize, v1[1], v1[2], v1[3], v1[4]);
    let mut hv: Vec<i64> = input_line();

    while a > 0 {
        let max_index = get_max_idx(&hv);
        if hv[max_index] <= 0 {
            break;
        }
        hv[max_index] -= x;
        if hv[max_index] < 0 {
            hv[max_index] = 0;
        }
        a -= 1;
    }

    let b_total = b * y;
    let r_total = hv.iter().fold(0, |acc, x| acc + x);

    println!("{}", if b_total >= r_total { "Yes" } else { "No" });
}

fn get_max_idx(v: &Vec<i64>) -> usize {
    let mut max = v[0];
    let mut result: usize = 0;
    for (i, vi) in v.iter().enumerate() {
        if *vi > max {
            max = *vi;
            result = i;
        }
    }
    result
}

fn input_line<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
0