結果

問題 No.2015 Stair Counter
ユーザー 👑 KazunKazun
提出日時 2022-07-22 21:34:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 86,764 KB
実行使用メモリ 108,616 KB
最終ジャッジ日時 2023-09-17 09:03:57
合計ジャッジ時間 4,439 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,068 KB
testcase_01 AC 118 ms
77,800 KB
testcase_02 AC 118 ms
77,436 KB
testcase_03 AC 119 ms
77,760 KB
testcase_04 AC 111 ms
77,708 KB
testcase_05 AC 108 ms
77,308 KB
testcase_06 AC 122 ms
77,376 KB
testcase_07 AC 121 ms
77,256 KB
testcase_08 AC 133 ms
77,504 KB
testcase_09 AC 89 ms
76,468 KB
testcase_10 AC 88 ms
76,348 KB
testcase_11 AC 89 ms
76,468 KB
testcase_12 AC 87 ms
76,744 KB
testcase_13 AC 89 ms
77,912 KB
testcase_14 AC 90 ms
77,360 KB
testcase_15 AC 102 ms
95,204 KB
testcase_16 AC 116 ms
105,212 KB
testcase_17 AC 106 ms
99,948 KB
testcase_18 AC 108 ms
98,732 KB
testcase_19 AC 120 ms
108,616 KB
testcase_20 AC 113 ms
106,608 KB
testcase_21 AC 115 ms
77,820 KB
testcase_22 AC 115 ms
77,364 KB
testcase_23 AC 120 ms
77,372 KB
testcase_24 AC 115 ms
78,024 KB
testcase_25 AC 116 ms
78,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N,M=map(int,input().split())
    A=[0]+list(map(int,input().split()))

    X=[0]*(N+1); X[0]=M
    for i in range(N):
        if X[i]+X[i+1]<A[i+1]:
            return False
        if i+2<=N:
            X[i+2]+=(X[i]+X[i+1])-A[i+1]
            if X[i+2]>A[i+2]:
                return False

        X[i+1]=A[i+1]
        X[i]=0
    return True

#==================================================
import sys
input=sys.stdin.readline
write=sys.stdout.write

T=int(input())

Ans=[0]*T
for t in range(T):
    Ans[t]="Yes" if solve() else "No"

write("\n".join(Ans))
0