結果

問題 No.1861 Required Number
ユーザー shiomusubi496shiomusubi496
提出日時 2022-03-04 16:29:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 277 ms / 2,500 ms
コード長 763 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 49,084 KB
最終ジャッジ日時 2023-09-26 03:10:45
合計ジャッジ時間 11,712 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
29,484 KB
testcase_01 AC 132 ms
29,496 KB
testcase_02 AC 132 ms
29,656 KB
testcase_03 AC 267 ms
48,980 KB
testcase_04 AC 277 ms
49,084 KB
testcase_05 AC 137 ms
29,612 KB
testcase_06 AC 136 ms
29,672 KB
testcase_07 AC 132 ms
29,568 KB
testcase_08 AC 134 ms
29,720 KB
testcase_09 AC 133 ms
29,548 KB
testcase_10 AC 136 ms
29,656 KB
testcase_11 AC 134 ms
29,676 KB
testcase_12 AC 134 ms
29,708 KB
testcase_13 AC 134 ms
29,652 KB
testcase_14 AC 134 ms
29,708 KB
testcase_15 AC 135 ms
29,732 KB
testcase_16 AC 133 ms
29,620 KB
testcase_17 AC 132 ms
29,672 KB
testcase_18 AC 137 ms
29,616 KB
testcase_19 AC 132 ms
29,756 KB
testcase_20 AC 132 ms
29,708 KB
testcase_21 AC 133 ms
29,604 KB
testcase_22 AC 133 ms
29,744 KB
testcase_23 AC 132 ms
29,572 KB
testcase_24 AC 192 ms
36,184 KB
testcase_25 AC 257 ms
46,372 KB
testcase_26 AC 200 ms
32,232 KB
testcase_27 AC 236 ms
35,280 KB
testcase_28 AC 218 ms
36,220 KB
testcase_29 AC 242 ms
33,304 KB
testcase_30 AC 239 ms
30,344 KB
testcase_31 AC 253 ms
46,476 KB
testcase_32 AC 238 ms
30,816 KB
testcase_33 AC 252 ms
41,068 KB
testcase_34 AC 254 ms
43,296 KB
testcase_35 AC 262 ms
43,564 KB
testcase_36 AC 238 ms
33,456 KB
testcase_37 AC 248 ms
36,188 KB
testcase_38 AC 253 ms
43,640 KB
testcase_39 AC 245 ms
37,284 KB
testcase_40 AC 259 ms
46,572 KB
testcase_41 AC 254 ms
45,552 KB
testcase_42 AC 263 ms
42,420 KB
testcase_43 AC 251 ms
36,296 KB
testcase_44 AC 135 ms
29,644 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][:K - A[i] + 1]
    for i in reversed(range(N)):
        dpr[i] = dpr[i + 1]
        dpr[i][A[i]:] |= dpr[i + 1][:K - A[i] + 1]
    if not dpl[N][K]:
        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