結果

問題 No.1861 Required Number
ユーザー shiomusubi496shiomusubi496
提出日時 2022-03-02 10:15:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 813 ms / 2,500 ms
コード長 851 bytes
コンパイル時間 1,714 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 226,492 KB
最終ジャッジ日時 2023-09-26 03:02:02
合計ジャッジ時間 27,699 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,204 KB
testcase_01 AC 140 ms
75,812 KB
testcase_02 AC 70 ms
71,308 KB
testcase_03 AC 790 ms
226,464 KB
testcase_04 AC 813 ms
226,492 KB
testcase_05 AC 70 ms
71,256 KB
testcase_06 AC 70 ms
71,572 KB
testcase_07 AC 79 ms
76,208 KB
testcase_08 AC 83 ms
76,092 KB
testcase_09 AC 77 ms
75,784 KB
testcase_10 AC 79 ms
75,916 KB
testcase_11 AC 82 ms
76,132 KB
testcase_12 AC 80 ms
76,008 KB
testcase_13 AC 84 ms
76,072 KB
testcase_14 AC 81 ms
76,104 KB
testcase_15 AC 82 ms
75,976 KB
testcase_16 AC 76 ms
75,964 KB
testcase_17 AC 82 ms
75,952 KB
testcase_18 AC 81 ms
76,104 KB
testcase_19 AC 85 ms
76,188 KB
testcase_20 AC 82 ms
75,828 KB
testcase_21 AC 82 ms
76,024 KB
testcase_22 AC 85 ms
76,168 KB
testcase_23 AC 85 ms
76,084 KB
testcase_24 AC 292 ms
130,840 KB
testcase_25 AC 557 ms
203,692 KB
testcase_26 AC 165 ms
90,060 KB
testcase_27 AC 281 ms
125,452 KB
testcase_28 AC 292 ms
133,924 KB
testcase_29 AC 204 ms
109,404 KB
testcase_30 AC 113 ms
84,528 KB
testcase_31 AC 557 ms
203,476 KB
testcase_32 AC 131 ms
88,384 KB
testcase_33 AC 443 ms
171,560 KB
testcase_34 AC 472 ms
180,584 KB
testcase_35 AC 482 ms
180,504 KB
testcase_36 AC 214 ms
111,492 KB
testcase_37 AC 291 ms
131,224 KB
testcase_38 AC 523 ms
193,304 KB
testcase_39 AC 315 ms
134,624 KB
testcase_40 AC 569 ms
203,432 KB
testcase_41 AC 540 ms
203,640 KB
testcase_42 AC 458 ms
180,304 KB
testcase_43 AC 297 ms
132,916 KB
testcase_44 AC 70 ms
71,188 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
                break
        if not_use:
            ans += 1
    print(ans)
0