結果

問題 No.1861 Required Number
ユーザー rin204
提出日時 2022-03-05 20:37:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 296 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 147,328 KB
最終ジャッジ日時 2024-07-20 02:59:22
合計ジャッジ時間 20,163 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41 WA * 1 TLE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = [False] * (2 * k + 1)
dp[0] = True

for a in A:
    for i in range(2 * k, a - 1, -1):
        dp[i] |= dp[i - a]

if not dp[k]:
    print(-1)
    exit()
ans = 0
for a in A:
    if not dp[a + k]:
        ans += 1
print(ans)
0