結果
| 問題 | No.2922 Rose Garden | 
| コンテスト | |
| ユーザー |  Jikky1618 | 
| 提出日時 | 2024-10-12 20:39:10 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,091 ms / 3,000 ms | 
| コード長 | 1,348 bytes | 
| コンパイル時間 | 3,111 ms | 
| コンパイル使用メモリ | 256,532 KB | 
| 実行使用メモリ | 5,632 KB | 
| 最終ジャッジ日時 | 2024-10-12 20:39:23 | 
| 合計ジャッジ時間 | 9,321 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 50 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include <debug_print.hpp>
#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (static_cast<void>(0))
#endif
template <class T, class U>
T ceil(T x, U y) {
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <class T, class U>
T floor(T x, U y) {
    return (x > 0 ? x / y : (x - y + 1) / y);
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N, S, B;
    cin >> N >> S >> B;
    vector<ll> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    // {id, stamina, height}
    queue<tuple<int, ll, ll>> que;
    que.emplace(0, S, H[0]);
    vector<int> seen(N); // 着地したか
    while (!que.empty()) {
        auto [id, s, h] = que.front();
        if (id == N - 1) {
            cout << "Yes" << '\n';
            return 0;
        }
        que.pop();
        // そのまま上昇して, 次の足場に移動
        if (h + s * B >= H[id + 1]) {
            ll diff = max<ll>(0, H[id + 1] - h);
            que.emplace(id + 1, s - ceil(diff, B), h + ceil(diff, B) * B);
        }
        // 一度地面につく
        if (seen[id]) continue;
        seen[id] = true;
        que.emplace(id, S, H[id]);
    }
    cout << "No" << '\n';
}
            
            
            
        