結果

問題 No.1238 選抜クラス
ユーザー irumo8202
提出日時 2022-01-28 13:09:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 76,636 KB
最終ジャッジ日時 2024-12-29 07:03:11
合計ジャッジ時間 3,478 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

MOD = 10 ** 9 + 7
N, K = map(int, input().split())
A = list(map(lambda x: int(x) - K, input().split()))

dp = defaultdict(int)
dp[0] = 1

for a in A:
    for key, cnt in dp.copy().items():
        dp[key + a] += cnt
        dp[key + a] %= MOD

ans = sum(cnt for key, cnt in dp.items() if key >= 0)
print((ans % MOD) - 1)
0