結果

問題 No.1238 選抜クラス
コンテスト
ユーザー qib
提出日時 2022-10-16 20:50:46
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 415 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 364 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 81,708 KB
最終ジャッジ日時 2026-03-15 14:17:16
合計ジャッジ時間 3,487 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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