結果

問題 No.2015 Stair Counter
ユーザー t98slidert98slider
提出日時 2022-07-25 10:16:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,139 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 169,344 KB
実行使用メモリ 6,888 KB
最終ジャッジ日時 2023-09-21 13:21:21
合計ジャッジ時間 5,936 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 37 ms
4,384 KB
testcase_02 AC 41 ms
4,380 KB
testcase_03 AC 43 ms
4,380 KB
testcase_04 AC 35 ms
4,380 KB
testcase_05 AC 32 ms
4,384 KB
testcase_06 AC 48 ms
4,380 KB
testcase_07 AC 47 ms
4,384 KB
testcase_08 AC 48 ms
4,384 KB
testcase_09 AC 26 ms
4,384 KB
testcase_10 AC 25 ms
4,380 KB
testcase_11 AC 29 ms
4,384 KB
testcase_12 AC 25 ms
4,384 KB
testcase_13 AC 26 ms
4,384 KB
testcase_14 AC 30 ms
4,384 KB
testcase_15 AC 36 ms
5,136 KB
testcase_16 AC 59 ms
5,788 KB
testcase_17 AC 25 ms
5,668 KB
testcase_18 AC 50 ms
5,596 KB
testcase_19 AC 61 ms
6,328 KB
testcase_20 AC 32 ms
6,888 KB
testcase_21 AC 35 ms
4,384 KB
testcase_22 AC 40 ms
4,384 KB
testcase_23 AC 46 ms
4,384 KB
testcase_24 AC 36 ms
4,380 KB
testcase_25 AC 36 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
}
0