結果

問題 No.1238 選抜クラス
ユーザー wolgnikwolgnik
提出日時 2020-09-25 21:49:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 76,256 KB
最終ジャッジ日時 2023-09-10 15:13:31
合計ジャッジ時間 5,059 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,380 KB
testcase_01 AC 75 ms
71,288 KB
testcase_02 AC 78 ms
75,440 KB
testcase_03 AC 75 ms
70,936 KB
testcase_04 AC 74 ms
71,316 KB
testcase_05 AC 74 ms
71,332 KB
testcase_06 AC 74 ms
71,204 KB
testcase_07 AC 77 ms
75,632 KB
testcase_08 AC 78 ms
75,672 KB
testcase_09 AC 84 ms
76,200 KB
testcase_10 AC 77 ms
75,580 KB
testcase_11 AC 83 ms
76,100 KB
testcase_12 AC 77 ms
75,644 KB
testcase_13 AC 78 ms
75,956 KB
testcase_14 AC 76 ms
75,596 KB
testcase_15 AC 80 ms
76,108 KB
testcase_16 AC 79 ms
76,000 KB
testcase_17 AC 87 ms
76,140 KB
testcase_18 AC 87 ms
76,180 KB
testcase_19 AC 87 ms
76,012 KB
testcase_20 AC 85 ms
76,116 KB
testcase_21 AC 83 ms
76,152 KB
testcase_22 AC 77 ms
75,828 KB
testcase_23 AC 84 ms
76,076 KB
testcase_24 AC 82 ms
76,256 KB
testcase_25 AC 77 ms
75,988 KB
testcase_26 AC 84 ms
76,156 KB
testcase_27 AC 85 ms
75,916 KB
testcase_28 AC 86 ms
75,968 KB
testcase_29 AC 90 ms
76,164 KB
testcase_30 AC 83 ms
76,020 KB
testcase_31 AC 84 ms
76,180 KB
testcase_32 AC 83 ms
76,108 KB
testcase_33 AC 76 ms
75,572 KB
testcase_34 AC 87 ms
76,164 KB
testcase_35 AC 84 ms
76,204 KB
testcase_36 AC 80 ms
76,096 KB
testcase_37 AC 82 ms
76,128 KB
testcase_38 AC 90 ms
76,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
a.sort()
for i in range(N): a[i] -= K
mn = []
zr = 0
pl = []
for x in a:
  if x < 0: mn.append(-x)
  elif x == 0: zr += 1
  else: pl.append(x)

ln = N * 100
dpmn = [0] * (ln + 1)
dpmn[0] = 1
dppl = [0] * (ln + 1)
dppl[0] = 1
for x in mn:
  for i in range(ln, -1, -1):
    if dpmn[i]:
      dpmn[i + x] += dpmn[i]
      dpmn[i + x] %= mod
for x in pl:
  for i in range(ln, -1, -1):
    if dppl[i]:
      dppl[i + x] += dppl[i]
      dppl[i + x] %= mod
for i in range(ln, 0, -1):
  dppl[i - 1] += dppl[i]
  dppl[i - 1] %= mod
res = 0
for i in range(ln + 1):
  res += dppl[i] * dpmn[i]
  res %= mod
print((res * pow(2, zr, mod) - 1) % mod)
0