結果

問題 No.1861 Required Number
ユーザー shiomusubi496shiomusubi496
提出日時 2022-03-02 10:07:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 807 ms / 2,500 ms
コード長 829 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 226,760 KB
最終ジャッジ日時 2023-09-26 03:01:32
合計ジャッジ時間 27,012 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,088 KB
testcase_01 AC 76 ms
75,884 KB
testcase_02 AC 71 ms
71,228 KB
testcase_03 AC 807 ms
226,468 KB
testcase_04 AC 780 ms
226,760 KB
testcase_05 AC 70 ms
71,448 KB
testcase_06 AC 69 ms
71,408 KB
testcase_07 AC 79 ms
76,116 KB
testcase_08 AC 88 ms
76,116 KB
testcase_09 AC 78 ms
76,008 KB
testcase_10 AC 85 ms
76,164 KB
testcase_11 AC 84 ms
76,244 KB
testcase_12 AC 81 ms
76,092 KB
testcase_13 AC 87 ms
76,188 KB
testcase_14 AC 82 ms
76,144 KB
testcase_15 AC 86 ms
75,952 KB
testcase_16 AC 77 ms
75,956 KB
testcase_17 AC 80 ms
75,892 KB
testcase_18 AC 85 ms
76,116 KB
testcase_19 AC 86 ms
75,892 KB
testcase_20 AC 84 ms
76,052 KB
testcase_21 AC 84 ms
76,128 KB
testcase_22 AC 86 ms
76,248 KB
testcase_23 AC 81 ms
76,056 KB
testcase_24 AC 341 ms
130,624 KB
testcase_25 AC 693 ms
203,812 KB
testcase_26 AC 196 ms
89,952 KB
testcase_27 AC 333 ms
125,516 KB
testcase_28 AC 357 ms
133,712 KB
testcase_29 AC 239 ms
109,524 KB
testcase_30 AC 125 ms
84,652 KB
testcase_31 AC 741 ms
216,100 KB
testcase_32 AC 146 ms
88,592 KB
testcase_33 AC 536 ms
171,772 KB
testcase_34 AC 584 ms
180,912 KB
testcase_35 AC 592 ms
180,748 KB
testcase_36 AC 245 ms
111,416 KB
testcase_37 AC 345 ms
131,236 KB
testcase_38 AC 645 ms
193,192 KB
testcase_39 AC 394 ms
134,728 KB
testcase_40 AC 741 ms
215,504 KB
testcase_41 AC 674 ms
203,892 KB
testcase_42 AC 564 ms
180,488 KB
testcase_43 AC 360 ms
132,896 KB
testcase_44 AC 72 ms
71,332 KB
04_evil_1.txt TLE -
04_evil_2.txt TLE -
04_evil_3.txt TLE -
04_evil_4.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dpl = [[False] * (K + 1) for _ in range(N + 1)]
dpr = [[False] * (K + 1) for _ in range(N + 1)]
dpl[0][0] = dpr[N][0] = True

for i in range(N):
    for j in range(K + 1):
        dpl[i + 1][j] = dpl[i][j]
    for j in range(0, K - A[i] + 1):
        if dpl[i][j]:
            dpl[i + 1][j + A[i]] = True
for i in range(N - 1, -1, -1):
    for j in range(K + 1):
        dpr[i][j] = dpr[i + 1][j]
    for j in range(0, K - A[i] + 1):
        if dpr[i + 1][j]:
            dpr[i][j + A[i]] = True
if not dpl[N][K]:
    print(-1)
else:
    ans = 0
    for i in range(N):
        not_use = True
        for j in range(K + 1):
            if dpl[i][j] and dpr[i + 1][K - j]:
                not_use = False
        if not_use:
            ans += 1
    print(ans)
0