結果
問題 |
No.2922 Rose Garden
|
ユーザー |
![]() |
提出日時 | 2024-10-12 14:55:14 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 85 ms / 3,000 ms |
コード長 | 1,140 bytes |
コンパイル時間 | 5,404 ms |
コンパイル使用メモリ | 335,272 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 14:55:25 |
合計ジャッジ時間 | 8,882 ms |
ジャッジサーバーID (参考情報) |
judge / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #define chmin(x,y) (x) = min((x),(y)) #define chmax(x,y) (x) = max((x),(y))z using namespace std; using namespace atcoder; using ll = long long; const ll mod = 998244353; using mint = modint998244353; using Graph = vector<vector<pair<int,ll>>>; const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1}; double dist(int x1, int y1, int x2, int y2){ double res = (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2); return sqrt(res); } ll need(ll n, ll m){ ll res = 0; if(n < 0) return res; res = n / m; if(n % m > 0) res++; return res; } int main(){ // input int N; ll S,B; cin >> N >> S >> B; vector<ll> H(N); for(int i = 0; i < N; i++) cin >> H[i]; // solve bool can = 1; ll hp = S, now = H[0]; for(int i = 1; i + 1 < N; i++){ if(now - H[i] <= (S - hp) * B){// chakuchi or not now = H[i]; hp = S; } if(now >= H[i+1]) continue; else if(now + B * hp >= H[i+1]){ ll use_hp = need(H[i+1] - now,B); now += B * use_hp; hp -= use_hp; } else can = 0; if(!can) break; } cout << (can ? "Yes" : "No") << endl; }