結果

問題 No.1238 選抜クラス
ユーザー shotoyooshotoyoo
提出日時 2020-09-25 21:41:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 76,376 KB
最終ジャッジ日時 2023-09-10 15:04:54
合計ジャッジ時間 4,968 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,068 KB
testcase_01 AC 73 ms
71,272 KB
testcase_02 AC 76 ms
76,252 KB
testcase_03 AC 74 ms
71,216 KB
testcase_04 AC 73 ms
71,168 KB
testcase_05 AC 74 ms
71,116 KB
testcase_06 AC 74 ms
71,552 KB
testcase_07 AC 77 ms
76,060 KB
testcase_08 AC 79 ms
76,112 KB
testcase_09 AC 80 ms
76,208 KB
testcase_10 AC 79 ms
76,324 KB
testcase_11 AC 78 ms
76,056 KB
testcase_12 AC 77 ms
76,164 KB
testcase_13 AC 80 ms
76,124 KB
testcase_14 AC 78 ms
75,952 KB
testcase_15 AC 78 ms
76,272 KB
testcase_16 AC 80 ms
76,168 KB
testcase_17 AC 89 ms
76,328 KB
testcase_18 AC 89 ms
76,304 KB
testcase_19 AC 88 ms
76,364 KB
testcase_20 AC 86 ms
76,232 KB
testcase_21 AC 87 ms
75,964 KB
testcase_22 AC 76 ms
71,116 KB
testcase_23 AC 93 ms
76,328 KB
testcase_24 AC 95 ms
76,260 KB
testcase_25 AC 74 ms
71,076 KB
testcase_26 AC 91 ms
76,264 KB
testcase_27 AC 88 ms
76,376 KB
testcase_28 AC 86 ms
76,172 KB
testcase_29 AC 87 ms
76,244 KB
testcase_30 AC 80 ms
76,180 KB
testcase_31 AC 86 ms
76,208 KB
testcase_32 AC 85 ms
76,252 KB
testcase_33 AC 73 ms
71,268 KB
testcase_34 AC 87 ms
76,204 KB
testcase_35 AC 82 ms
76,132 KB
testcase_36 AC 82 ms
76,112 KB
testcase_37 AC 86 ms
76,192 KB
testcase_38 AC 88 ms
76,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
a = [item-k for item in a]
ma = sum([-item for item in a if item<0])
Ma = sum([item for item in a if item>0])
dp = [0]*(ma+Ma+10)
dp[ma] = 1
M = 10**9+7
for i in range(n):
    ndp = [0]*(ma+Ma+10)
    for j in range(ma+Ma+10):
        ndp[j] = dp[j]
        if 0<=j-a[i]<ma+Ma+10:
            ndp[j] += dp[j-a[i]]
        ndp[j] %= M
    dp = ndp
#     print(dp)
ans = sum(dp[j] for j in range(ma, ma+Ma+1))-1
print(ans%M)
0