結果
問題 | No.2015 Stair Counter |
ユーザー |
![]() |
提出日時 | 2022-07-28 01:00:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 633 bytes |
コンパイル時間 | 597 ms |
コンパイル使用メモリ | 64,160 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-07-17 14:46:27 |
合計ジャッジ時間 | 3,237 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
#include <iostream> #define int long long #define rep(i, n) for(i = 0; i < n; i++) using namespace std; int n, m; int a[200001]; int b[200002]; bool solve() { int i; rep(i, n + 1) b[i] = 0; b[0] = m; rep(i, n) { int x = a[i + 1] - b[i + 1]; if (x < 0 || x > b[i]) { return false; } b[i + 1] += x; b[i + 2] += b[i] - x; } for (i = 1; i <= n; i++) if (b[i] != a[i]) { return false; } return true; } signed main() { int t; cin >> t; while (t--) { cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i + 1]; bool res = solve(); if (res) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }