結果
問題 |
No.2015 Stair Counter
|
ユーザー |
![]() |
提出日時 | 2022-07-23 15:50:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 770 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 41,472 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 05:02:07 |
合計ジャッジ時間 | 2,373 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
/* -*- coding: utf-8 -*- * * 2015.cc: No.2015 Stair Counter - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ /* global variables */ int as[MAX_N + 1]; /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", as + i); as[0] = m; bool ok = true; for (int i = 1; i <= n; i++) { int d = as[i]; if (i > 1) { if (as[i - 2] > d) { ok = false; break; } d -= as[i - 2]; } if (d > as[i - 1]) { ok = false; break; } as[i - 1] -= d; } if (ok && as[n - 1] == 0) puts("Yes"); else puts("No"); } return 0; }