結果
問題 |
No.1736 Princess vs. Dragoness
|
ユーザー |
|
提出日時 | 2022-01-07 21:49:50 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 1,450 bytes |
コンパイル時間 | 12,697 ms |
コンパイル使用メモリ | 385,508 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 08:40:56 |
合計ジャッジ時間 | 14,502 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
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 }