結果

問題 No.1555 Constructed Balancing Sequence
ユーザー maspymaspy
提出日時 2021-05-30 03:04:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 19,816 KB
最終ジャッジ日時 2023-09-04 22:08:56
合計ジャッジ時間 4,755 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,892 KB
testcase_01 AC 16 ms
7,980 KB
testcase_02 AC 16 ms
7,780 KB
testcase_03 AC 16 ms
7,888 KB
testcase_04 AC 17 ms
7,888 KB
testcase_05 AC 16 ms
7,792 KB
testcase_06 AC 17 ms
7,812 KB
testcase_07 AC 17 ms
7,840 KB
testcase_08 AC 16 ms
7,844 KB
testcase_09 AC 17 ms
7,876 KB
testcase_10 AC 16 ms
7,836 KB
testcase_11 AC 16 ms
7,832 KB
testcase_12 AC 107 ms
16,964 KB
testcase_13 AC 109 ms
17,208 KB
testcase_14 AC 111 ms
18,104 KB
testcase_15 AC 99 ms
17,796 KB
testcase_16 AC 110 ms
17,960 KB
testcase_17 AC 17 ms
8,340 KB
testcase_18 AC 103 ms
19,740 KB
testcase_19 AC 102 ms
19,604 KB
testcase_20 AC 102 ms
19,664 KB
testcase_21 AC 102 ms
19,564 KB
testcase_22 AC 102 ms
19,712 KB
testcase_23 AC 104 ms
19,612 KB
testcase_24 AC 103 ms
19,568 KB
testcase_25 AC 103 ms
19,656 KB
testcase_26 AC 104 ms
19,656 KB
testcase_27 AC 103 ms
19,672 KB
testcase_28 AC 75 ms
16,296 KB
testcase_29 AC 94 ms
18,652 KB
testcase_30 AC 92 ms
18,624 KB
testcase_31 AC 62 ms
14,244 KB
testcase_32 AC 95 ms
18,868 KB
testcase_33 AC 94 ms
18,620 KB
testcase_34 AC 62 ms
14,160 KB
testcase_35 AC 66 ms
15,096 KB
testcase_36 AC 73 ms
15,960 KB
testcase_37 AC 78 ms
16,476 KB
testcase_38 AC 16 ms
7,968 KB
testcase_39 AC 16 ms
7,944 KB
testcase_40 AC 16 ms
7,924 KB
testcase_41 AC 16 ms
7,836 KB
testcase_42 AC 17 ms
7,824 KB
testcase_43 AC 106 ms
19,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998_244_353

def main(N, K, A):
    S = [0] * (N+1)
    for i in range(N):
        S[i+1] = S[i] + A[i]
    if any(a > b for a, b in zip(A[1:], S[1:])):
        return 0
    v = A[-1] - 1
    ans = 1
    for n in range(N - 2, -1, -1):
        s, a = S[n], A[n]
        if v < s + a - 1:
            pass
        else:
            ans = ans * (A[n] + K + 1) % MOD
        v = max(A[n] - 1, v // 2)
    return ans

N, K = map(int, input().split())
A = list(map(int, input().split()))
print(main(N, K, A))
0