結果

問題 No.2015 Stair Counter
ユーザー firkirb
提出日時 2022-07-25 00:49:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 1,718 ms
コンパイル使用メモリ 167,640 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 20:39:13
合計ジャッジ時間 3,735 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <string>
#include <algorithm>
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+1);
    a.at(0) = m;
    for (int j=1; j<n+1; j++){
      cin >> a.at(j);
    }
    int x = 0;
    bool flag = true;
    for (int j=1; j<n+1; j++){
      if (a.at(j) < x || a.at(j) - x > a.at(j-1)){
        flag = false;
        break;
      } else {
        x = a.at(j-1) - (a.at(j) - x);
      }
    }
    cout << (flag? "Yes" : "No") << endl;
  }
}
0