結果

問題 No.2015 Stair Counter
ユーザー HaaHaa
提出日時 2022-07-22 21:28:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 945 bytes
コンパイル時間 1,965 ms
コンパイル使用メモリ 167,620 KB
実行使用メモリ 6,320 KB
最終ジャッジ日時 2023-09-17 08:52:50
合計ジャッジ時間 3,877 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 36 ms
4,356 KB
testcase_02 AC 41 ms
4,352 KB
testcase_03 AC 43 ms
4,356 KB
testcase_04 AC 35 ms
4,360 KB
testcase_05 AC 32 ms
4,380 KB
testcase_06 AC 47 ms
4,360 KB
testcase_07 AC 47 ms
4,356 KB
testcase_08 AC 47 ms
4,356 KB
testcase_09 AC 24 ms
4,356 KB
testcase_10 AC 25 ms
4,352 KB
testcase_11 AC 28 ms
4,352 KB
testcase_12 AC 25 ms
4,356 KB
testcase_13 AC 26 ms
4,352 KB
testcase_14 AC 30 ms
4,356 KB
testcase_15 AC 35 ms
4,880 KB
testcase_16 AC 58 ms
5,716 KB
testcase_17 AC 25 ms
5,360 KB
testcase_18 AC 50 ms
5,668 KB
testcase_19 AC 61 ms
6,196 KB
testcase_20 AC 31 ms
6,320 KB
testcase_21 AC 34 ms
4,352 KB
testcase_22 AC 40 ms
4,360 KB
testcase_23 AC 45 ms
4,384 KB
testcase_24 AC 36 ms
4,356 KB
testcase_25 AC 36 ms
4,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

void solve(){
    ll n, m; cin >> n >> m;
    VI a(n+2,0); REP(i,n) cin >> a[i];
    VI b(n+2,0); b[0]=m;
    REP(i,n){
        int x=a[i]-b[i+1];
        int y=a[i+1]-b[i+2];
        if(x<0||y<0){
            cout << "No" << endl;
            return;
        }
        b[i+1]+=x;
        b[i+2]+=b[i]-x;
        if(a[i]!=b[i+1]||x>b[i]){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main(){
    int t; cin >> t;
    while(t--) solve();
    return 0;
}
0