結果
| 問題 | No.2922 Rose Garden |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 17:09:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,170 bytes |
| 記録 | |
| コンパイル時間 | 681 ms |
| コンパイル使用メモリ | 69,120 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 17:09:13 |
| 合計ジャッジ時間 | 4,536 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 25 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
string canReachLastPlatform(int N, int S, int B, vector<int>& H) {
int stamina = S;
int altitude = H[0]; // 初期高度は H[1](配列では H[0])
for (int i = 0; i < N - 1; ++i) {
int next_height = H[i + 1];
// 次の足場に行く前に必要ならば高度を上げる
if (altitude < next_height) {
int needed_stamina = (next_height - altitude + B - 1) / B; // 切り上げ計算
if (stamina >= needed_stamina) {
stamina -= needed_stamina;
altitude += needed_stamina * B;
} else {
return "No";
}
}
// 次の足場に移動可能か確認
if (altitude >= next_height) {
// 足場に着地してスタミナを回復
stamina = S;
altitude = next_height;
}
}
return "Yes";
}
int main() {
int N, S, B;
cin >> N >> S >> B;
vector<int> H(N);
for (int i = 0; i < N; ++i) {
cin >> H[i];
}
cout << canReachLastPlatform(N, S, B, H) << endl;
return 0;
}