結果

問題 No.2922 Rose Garden
ユーザー Spica
提出日時 2024-10-12 15:23:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 87 ms / 3,000 ms
コード長 2,066 bytes
コンパイル時間 3,878 ms
コンパイル使用メモリ 250,052 KB
最終ジャッジ日時 2025-02-24 18:01:47
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long; // -2^63 ~ 2^63-1 (9.2*10^18)
using ull = unsigned long long; // 0 ~ 2^64-1 (1.8*10^19)
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for (int i = (m); (i) < int (n); i++)
#define all(v) v.begin(), v.end()
#define bit(n) (1ll<<(n)) // 2^n
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define pb emplace_back
template<class T> using maxpq = priority_queue<T>;
template<class T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll llINF = 1000000000000000000;
void YesNo(bool flag){
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}
// 多次元vector生成
template<ll idx = 0, ll n, class T>
auto make_vec(const ll (&d)[n], T&& init) noexcept {
    if constexpr (idx < n) return std::vector(d[idx], make_vec<idx + 1>(d, std::forward<T>(init)));
    else return init;
}
template<class T, ll idx = 0, ll n>
auto make_vec(const ll (&d)[n], const T& init = {}) noexcept {
    if constexpr (idx < n) return std::vector(d[idx], make_vec<idx + 1>(d, init));
    else return init;
}
// auto 変数名 = make_vec<型>({a, b, ...}, 初期値);

ll my_ceil(ll a, ll b){
    if(a > 0){
        return (a-1)/b + 1;
    }
    else{
        return a/b;
    }
}

int main(){
    ll N, S, B;
    cin >> N >> S >> B;
    vector<ll> H(N);
    rep(i, N){
        cin >> H[i];
    }

    ll nowS = S, now = H[0];
    rep(i, N-1){
        if(now < H[i+1]){
            nowS -= my_ceil(H[i+1]-now, B);
            now += B*my_ceil(H[i+1]-now, B);
            if(nowS < 0){
                cout << "No" << endl;
                return 0;
            }
        }

        if(now-H[i+1] < B*(S-nowS)){
            now = H[i+1];
            nowS = S;
        }
    }
    cout << "Yes" << endl;
}
0