結果
| 問題 | No.2922 Rose Garden | 
| コンテスト | |
| ユーザー |  urectanc | 
| 提出日時 | 2025-03-26 22:21:13 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 17 ms / 3,000 ms | 
| コード長 | 859 bytes | 
| コンパイル時間 | 14,886 ms | 
| コンパイル使用メモリ | 377,600 KB | 
| 実行使用メモリ | 5,888 KB | 
| 最終ジャッジ日時 | 2025-03-26 22:21:31 | 
| 合計ジャッジ時間 | 15,212 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 50 | 
ソースコード
use proconio::input;
fn main() {
    input! {
        n: i64, s: i64, b: i64,
        h: [i64; n]
    }
    let (mut stamina, mut height) = (s, h[0]);
    for w in h.windows(2) {
        let (current, next) = (w[0], w[1]);
        let r0 = ((next - height).max(0) + b - 1) / b;
        let r1 = ((next - current).max(0) + b - 1) / b;
        let s0 = stamina - r0;
        let s1 = s - r1;
        if s0 < 0 && s1 < 0 {
            println!("No");
            return;
        }
        let h0 = height + r0 * b;
        let h1 = current + r1 * b;
        (stamina, height) = if s0 >= 0 && s1 < 0 {
            (s0, h0)
        } else if s0 < 0 {
            (s1, h1)
        } else {
            if h0 + s0 * b > h1 + s1 * b {
                (s0, h0)
            } else {
                (s1, h1)
            }
        };
    }
    println!("Yes");
}
            
            
            
        