結果

問題 No.2015 Stair Counter
ユーザー GrayCoderGrayCoder
提出日時 2022-07-23 02:03:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 30,036 KB
最終ジャッジ日時 2023-09-17 16:14:03
合計ジャッジ時間 3,777 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,760 KB
testcase_01 AC 71 ms
8,424 KB
testcase_02 AC 77 ms
8,324 KB
testcase_03 AC 84 ms
8,264 KB
testcase_04 AC 69 ms
8,284 KB
testcase_05 AC 65 ms
8,220 KB
testcase_06 AC 88 ms
8,308 KB
testcase_07 AC 87 ms
8,324 KB
testcase_08 AC 87 ms
8,280 KB
testcase_09 AC 57 ms
8,628 KB
testcase_10 AC 60 ms
8,616 KB
testcase_11 AC 62 ms
8,720 KB
testcase_12 AC 59 ms
10,812 KB
testcase_13 AC 60 ms
11,760 KB
testcase_14 AC 60 ms
11,016 KB
testcase_15 AC 94 ms
22,380 KB
testcase_16 AC 121 ms
27,044 KB
testcase_17 AC 67 ms
10,968 KB
testcase_18 AC 112 ms
25,060 KB
testcase_19 AC 141 ms
30,036 KB
testcase_20 AC 71 ms
11,488 KB
testcase_21 AC 68 ms
8,292 KB
testcase_22 AC 76 ms
8,340 KB
testcase_23 AC 83 ms
8,240 KB
testcase_24 AC 70 ms
8,272 KB
testcase_25 AC 70 ms
8,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def main():
    input = lambda: sys.stdin.readline()[:-1]
    T = int(input())
    for _ in [0] * T:
        N, M = map(int, input().split())
        A = [M] + list(map(int, input().split()))

        if A[0] < A[1]:
            print("No")
            continue

        a = [0] * (N + 1)
        a[0], a[1] = A[0] - A[1], A[1]
        for i in range(2, N + 1):
            a[i] += a[i - 2]
            a[i - 2] = 0
            if a[i] > A[i]:
                print("No")
                break
            if a[i - 1] + a[i] < A[i]:
                print("No")
                break
            a[i - 1] -= A[i] - a[i]
            a[i] = A[i]
        else:
            print("Yes")


if not __debug__:
    f = open(sys.argv[1], "r")
    sys.stdin = f

main()
0