結果

問題 No.1861 Required Number
ユーザー ChipppppChippppp
提出日時 2022-03-05 14:37:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 294 ms / 2,500 ms
コード長 763 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 49,040 KB
最終ジャッジ日時 2023-09-27 01:45:15
合計ジャッジ時間 13,457 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
29,580 KB
testcase_01 AC 136 ms
29,608 KB
testcase_02 AC 137 ms
29,576 KB
testcase_03 AC 294 ms
48,908 KB
testcase_04 AC 287 ms
49,040 KB
testcase_05 AC 140 ms
29,484 KB
testcase_06 AC 140 ms
29,636 KB
testcase_07 AC 140 ms
29,576 KB
testcase_08 AC 140 ms
29,596 KB
testcase_09 AC 139 ms
29,520 KB
testcase_10 AC 139 ms
29,540 KB
testcase_11 AC 139 ms
29,764 KB
testcase_12 AC 139 ms
29,604 KB
testcase_13 AC 140 ms
29,612 KB
testcase_14 AC 138 ms
29,520 KB
testcase_15 AC 139 ms
29,668 KB
testcase_16 AC 140 ms
29,512 KB
testcase_17 AC 139 ms
29,608 KB
testcase_18 AC 137 ms
29,620 KB
testcase_19 AC 142 ms
29,820 KB
testcase_20 AC 142 ms
29,676 KB
testcase_21 AC 139 ms
29,628 KB
testcase_22 AC 143 ms
29,708 KB
testcase_23 AC 140 ms
29,596 KB
testcase_24 AC 201 ms
35,996 KB
testcase_25 AC 273 ms
46,072 KB
testcase_26 AC 205 ms
32,048 KB
testcase_27 AC 244 ms
35,276 KB
testcase_28 AC 228 ms
36,316 KB
testcase_29 AC 245 ms
33,084 KB
testcase_30 AC 244 ms
30,256 KB
testcase_31 AC 285 ms
46,548 KB
testcase_32 AC 243 ms
30,708 KB
testcase_33 AC 260 ms
41,132 KB
testcase_34 AC 269 ms
43,300 KB
testcase_35 AC 270 ms
43,376 KB
testcase_36 AC 244 ms
33,476 KB
testcase_37 AC 260 ms
36,180 KB
testcase_38 AC 266 ms
43,748 KB
testcase_39 AC 252 ms
37,200 KB
testcase_40 AC 279 ms
46,684 KB
testcase_41 AC 272 ms
45,556 KB
testcase_42 AC 267 ms
42,500 KB
testcase_43 AC 250 ms
36,092 KB
testcase_44 AC 137 ms
29,576 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