結果

問題 No.2015 Stair Counter
ユーザー TatsuyaaaaTatsuyaaaa
提出日時 2022-07-22 21:28:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 2,097 ms
コンパイル使用メモリ 198,868 KB
実行使用メモリ 4,684 KB
最終ジャッジ日時 2023-09-17 08:52:57
合計ジャッジ時間 3,727 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 12 ms
4,380 KB
testcase_02 AC 13 ms
4,376 KB
testcase_03 AC 13 ms
4,380 KB
testcase_04 AC 11 ms
4,376 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 14 ms
4,376 KB
testcase_07 AC 14 ms
4,380 KB
testcase_08 AC 13 ms
4,376 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 10 ms
4,380 KB
testcase_11 AC 11 ms
4,376 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 AC 10 ms
4,376 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 AC 14 ms
4,376 KB
testcase_16 AC 20 ms
4,420 KB
testcase_17 AC 12 ms
4,380 KB
testcase_18 AC 18 ms
4,376 KB
testcase_19 AC 22 ms
4,568 KB
testcase_20 AC 14 ms
4,684 KB
testcase_21 AC 12 ms
4,376 KB
testcase_22 AC 12 ms
4,380 KB
testcase_23 AC 13 ms
4,380 KB
testcase_24 AC 12 ms
4,380 KB
testcase_25 AC 12 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    for (int i=0;i<T;i++) {
        int n;
        ll m;
        cin >> n >> m;
        vector<ll> A(n);
        for (int j=0;j<n;j++) cin >> A[j];

        bool ans = true;

        ll num0 = m;
        ll num1 = 0LL;
        for (int j=0;j<n;j++) {
            ll diff = A[j]-num1;
            if (diff < 0) ans = false;
            num0 -= diff;
            if (num0 < 0) ans = false;
            
            ll tmp = num0;

            num0 = A[j];
            num1 = tmp;
        }

        if (ans) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }
    return 0;
}
0