結果

問題 No.1861 Required Number
ユーザー shiomusubi496shiomusubi496
提出日時 2022-03-02 11:44:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 656 ms / 2,500 ms
コード長 827 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 226,188 KB
最終ジャッジ日時 2023-09-26 03:09:13
合計ジャッジ時間 16,201 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,332 KB
testcase_01 AC 83 ms
75,852 KB
testcase_02 AC 75 ms
71,420 KB
testcase_03 AC 605 ms
226,164 KB
testcase_04 AC 656 ms
226,188 KB
testcase_05 AC 77 ms
71,144 KB
testcase_06 AC 74 ms
71,336 KB
testcase_07 AC 84 ms
75,864 KB
testcase_08 AC 87 ms
76,032 KB
testcase_09 AC 80 ms
75,992 KB
testcase_10 AC 84 ms
75,832 KB
testcase_11 AC 89 ms
76,044 KB
testcase_12 AC 83 ms
76,012 KB
testcase_13 AC 88 ms
75,764 KB
testcase_14 AC 90 ms
75,964 KB
testcase_15 AC 88 ms
76,028 KB
testcase_16 AC 84 ms
76,004 KB
testcase_17 AC 88 ms
75,940 KB
testcase_18 AC 85 ms
75,960 KB
testcase_19 AC 88 ms
75,920 KB
testcase_20 AC 86 ms
75,740 KB
testcase_21 AC 85 ms
75,940 KB
testcase_22 AC 86 ms
76,032 KB
testcase_23 AC 88 ms
76,140 KB
testcase_24 AC 239 ms
130,756 KB
testcase_25 AC 443 ms
203,596 KB
testcase_26 AC 152 ms
89,792 KB
testcase_27 AC 228 ms
125,416 KB
testcase_28 AC 248 ms
133,520 KB
testcase_29 AC 184 ms
109,508 KB
testcase_30 AC 112 ms
84,500 KB
testcase_31 AC 460 ms
216,040 KB
testcase_32 AC 126 ms
88,300 KB
testcase_33 AC 342 ms
171,260 KB
testcase_34 AC 388 ms
180,620 KB
testcase_35 AC 383 ms
180,204 KB
testcase_36 AC 192 ms
111,120 KB
testcase_37 AC 244 ms
131,020 KB
testcase_38 AC 400 ms
193,276 KB
testcase_39 AC 257 ms
134,436 KB
testcase_40 AC 459 ms
215,264 KB
testcase_41 AC 434 ms
203,396 KB
testcase_42 AC 374 ms
180,320 KB
testcase_43 AC 248 ms
132,724 KB
testcase_44 AC 76 ms
71,088 KB
04_evil_1.txt MLE -
04_evil_2.txt MLE -
04_evil_3.txt MLE -
04_evil_4.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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]] = 1
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]] = 1
if not dpl[N][K]:
    print(-1)
else:
    ans = 0
    for i in range(N):
        not_use = 1
        for j in range(K + 1):
            if dpl[i][j] and dpr[i + 1][K - j]:
                not_use = 0
                break
        if not_use:
            ans += 1
    print(ans)
0