結果
問題 | No.2015 Stair Counter |
ユーザー |
![]() |
提出日時 | 2022-07-29 15:57:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 1,775 ms |
コンパイル使用メモリ | 168,796 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 07:12:55 |
合計ジャッジ時間 | 3,873 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; for( int i = 0; i < T; i++ ) { int N, M; cin >> N >> M; vector<int> A( N ), a( N + 1 ); for( int j = 0; j < N; j++ ) cin >> A[j]; a[0] = M; string ans = "Yes"; for( int j = 0; j < N; j++ ) { int l, h; if( j == 0 ) { l = 0; h = M; if( A[j] < l || h < A[j] ) { ans = "No"; break; } a[j + 1] = A[j]; a[j] -= A[j]; } else if( j ) { l = a[j - 1]; h = a[j - 1] + a[j]; if( A[j] < l || h < A[j] ) { ans = "No"; break; } a[j + 1] = A[j]; a[j] = h - A[j]; } } cout << ans << endl; } }