use proconio::input; fn main() { input! { (n, s, b): (usize, usize, usize), hh: [usize; n], } // dp[i]: スタミナがiのときの最高高度 let mut dp = vec![None; s + 1]; dp[s] = Some(hh[0]); let mut next_dp = vec![None; s + 1]; for &h in &hh[1..] { for (stamina, &max_height) in dp.iter().enumerate() { let Some(max_height) = max_height else { continue; }; let consumption = (h.saturating_sub(max_height) + b - 1) / b; if consumption <= stamina { chmax_for_option( &mut next_dp[stamina - consumption], max_height + b * consumption, ); chmax_for_option(&mut next_dp[s], h); } } std::mem::swap(&mut dp, &mut next_dp); next_dp.fill(None); } let ans = dp.iter().any(|max_height| max_height.is_some()); println!("{}", if ans { "Yes" } else { "No" }); } /// If `value` is `None` or contains a value less than `cand_value`, update it to `Some(cand_value)`. /// /// Returns whether `value` has been updated or not as a bool value. /// /// # Arguments /// /// * `value` - Reference variable to be updated. /// * `cand_value` - Candidate value for update. pub fn chmax_for_option(value: &mut Option, cand_value: T) -> bool where T: PartialOrd, { if value.as_ref().is_some_and(|cost| cost >= &cand_value) { return false; } *value = Some(cand_value); true }