結果

問題 No.1861 Required Number
ユーザー rlangevinrlangevin
提出日時 2023-03-13 08:52:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 404 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 331,696 KB
最終ジャッジ日時 2023-10-18 10:54:46
合計ジャッジ時間 22,673 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
60,400 KB
testcase_01 AC 44 ms
64,308 KB
testcase_02 AC 38 ms
57,736 KB
testcase_03 AC 191 ms
331,696 KB
testcase_04 WA -
testcase_05 AC 37 ms
309,160 KB
testcase_06 WA -
testcase_07 AC 46 ms
59,724 KB
testcase_08 AC 45 ms
61,628 KB
testcase_09 AC 43 ms
59,576 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 46 ms
61,772 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 44 ms
59,580 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
04_evil_1.txt TLE -
04_evil_2.txt TLE -
04_evil_3.txt TLE -
04_evil_4.txt TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

pre = [0] * (2 * K + 1)
pre[0] = 1
for i in range(N):
    dp = [0] * (2 * K + 1)
    for j in range(2 * K + 1):
        dp[j] |= pre[j]
        if j - A[i] >= 0:
            dp[j] |= pre[j - A[i]]
    dp, pre = pre, dp

ans = 0
for i in range(N):
    if pre[K] and not pre[K + A[i]]:
        ans += 1

print(ans) if ans else print(-1)
0