結果

問題 No.1861 Required Number
ユーザー shiomusubi496shiomusubi496
提出日時 2022-03-04 16:07:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 752 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 33,296 KB
最終ジャッジ日時 2023-09-26 03:10:29
合計ジャッジ時間 9,177 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
29,744 KB
testcase_01 AC 141 ms
29,668 KB
testcase_02 AC 140 ms
29,692 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 140 ms
29,680 KB
testcase_08 RE -
testcase_09 AC 136 ms
29,524 KB
testcase_10 AC 138 ms
29,648 KB
testcase_11 AC 137 ms
29,648 KB
testcase_12 AC 138 ms
29,536 KB
testcase_13 AC 139 ms
29,628 KB
testcase_14 AC 139 ms
29,704 KB
testcase_15 RE -
testcase_16 AC 139 ms
29,592 KB
testcase_17 AC 137 ms
29,556 KB
testcase_18 AC 139 ms
29,696 KB
testcase_19 AC 142 ms
29,900 KB
testcase_20 AC 140 ms
29,676 KB
testcase_21 RE -
testcase_22 AC 142 ms
29,816 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 AC 137 ms
29,580 KB
04_evil_1.txt RE -
04_evil_2.txt RE -
04_evil_3.txt RE -
04_evil_4.txt RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    readline = sys.stdin.readline
    import numpy as np

    N, K = map(int, readline().split())
    A = np.fromstring(readline(), dtype = np.int64, sep = ' ')

    dpl = np.zeros((N + 1, K + 1), dtype = bool)
    dpr = np.zeros((N + 1, K + 1), dtype = bool)
    dpl[0][0] = dpr[N][0] = True

    for i in range(N):
        dpl[i + 1] = dpl[i]
        dpl[i + 1][A[i]:] |= dpl[i][:-A[i]]
    for i in reversed(range(N)):
        dpr[i] = dpr[i + 1]
        dpr[i][A[i]:] |= dpr[i + 1][:-A[i]]
    if not dpl[-1][-1]:
        print(-1)
    else:
        ans = 0
        for i in range(N):
            if not np.any(dpl[i] & dpr[i + 1][::-1]):
                ans += 1
        print(ans)
if __name__ == '__main__':
    main()
0