結果

問題 No.2922 Rose Garden
ユーザー urectanc
提出日時 2025-03-26 22:11:12
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 14,090 ms
コンパイル使用メモリ 379,616 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2025-03-26 22:11:30
合計ジャッジ時間 16,208 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

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 s0 = ((next - height).max(0) + b - 1) / b;
        let s1 = ((next - current).max(0) + b - 1) / b;
        if s0 > stamina && s1 > s {
            println!("No");
            return;
        }
        (stamina, height) = if stamina - s0 > s - s1 {
            (stamina - s0, height + s0 * b)
        } else {
            (s - s1, current + s1 * b)
        };
    }

    println!("Yes");
}
0