結果

問題 No.1238 選抜クラス
ユーザー qib
提出日時 2022-10-16 20:50:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 82,296 KB
実行使用メモリ 77,104 KB
最終ジャッジ日時 2024-06-27 14:47:03
合計ジャッジ時間 4,145 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

from collections import defaultdict

n, k = map(int, input().split())
a = list(map(int, input().split()))

dp = defaultdict(int)
dp[0] = 1
for i in range(n):
  ndp = defaultdict(int)
  for x, v in dp.items():
    ndp[x] = (ndp[x] + v) % MOD
    ndp[x + a[i] - k] = (ndp[x + a[i] - k] + v) % MOD

  dp = ndp

ans = 0
for x, v in dp.items():
	if x >= 0:
		ans = (ans + v) % MOD

ans -= 1
print(ans)
0