結果
問題 | No.2015 Stair Counter |
ユーザー |
|
提出日時 | 2022-07-25 10:16:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 1,139 bytes |
コンパイル時間 | 1,494 ms |
コンパイル使用メモリ | 172,700 KB |
実行使用メモリ | 6,400 KB |
最終ジャッジ日時 | 2024-07-07 07:03:45 |
合計ジャッジ時間 | 4,342 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(){ int T; cin >> T; while(T--){ ll n, m; cin >> n >> m; vector<ll> a(n); for(auto &&v:a)cin >> v; reverse(a.begin(), a.end()); a.push_back(m); auto b = a; bool ans = true; for(int i = 0; i + 1 <= n; i++){ int pre1 = b[i + 1]; int pre2 = a[i] - pre1; //a[i + 1] -= pre2; if(pre2){ if(i + 1 == n){ ans = false; break; } b[i + 2] -= pre2; if(b[i + 2] < 0)ans = false; } /*reverse(a.begin(), a.end()); for(int i = 0; i <= n; i++){ cerr << a[i] << " "; } cerr << '\n'; reverse(a.begin(), a.end());*/ } /*reverse(a.begin(), a.end()); for(int i = 0; i <= n; i++){ cerr << a[i] << " "; if(a[i] < 0)ans = false; } cerr << '\n';*/ cout << (ans ? "Yes" : "No") << endl; } }