結果

問題 No.1238 選抜クラス
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-13 01:33:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 617 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,088 KB
実行使用メモリ 75,940 KB
最終ジャッジ日時 2024-05-01 11:11:40
合計ジャッジ時間 3,197 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
61,120 KB
testcase_01 AC 45 ms
62,152 KB
testcase_02 AC 43 ms
62,460 KB
testcase_03 AC 40 ms
60,260 KB
testcase_04 AC 39 ms
61,372 KB
testcase_05 AC 40 ms
60,948 KB
testcase_06 AC 41 ms
61,424 KB
testcase_07 AC 45 ms
61,992 KB
testcase_08 AC 42 ms
63,020 KB
testcase_09 AC 43 ms
64,536 KB
testcase_10 AC 45 ms
61,500 KB
testcase_11 AC 45 ms
64,668 KB
testcase_12 AC 45 ms
63,252 KB
testcase_13 AC 42 ms
64,384 KB
testcase_14 AC 42 ms
62,704 KB
testcase_15 AC 42 ms
63,192 KB
testcase_16 AC 42 ms
64,136 KB
testcase_17 AC 52 ms
75,700 KB
testcase_18 AC 53 ms
75,624 KB
testcase_19 AC 53 ms
75,472 KB
testcase_20 AC 52 ms
75,668 KB
testcase_21 AC 55 ms
75,940 KB
testcase_22 AC 53 ms
75,912 KB
testcase_23 AC 55 ms
75,556 KB
testcase_24 AC 51 ms
75,772 KB
testcase_25 AC 53 ms
75,608 KB
testcase_26 AC 53 ms
75,652 KB
testcase_27 AC 54 ms
75,472 KB
testcase_28 AC 53 ms
75,508 KB
testcase_29 AC 53 ms
75,376 KB
testcase_30 AC 44 ms
65,596 KB
testcase_31 AC 45 ms
69,864 KB
testcase_32 AC 47 ms
73,620 KB
testcase_33 AC 40 ms
62,004 KB
testcase_34 AC 50 ms
74,320 KB
testcase_35 AC 45 ms
67,296 KB
testcase_36 AC 42 ms
62,996 KB
testcase_37 AC 47 ms
66,420 KB
testcase_38 AC 54 ms
75,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
U = 10000

N, K = map(int, input().split())
A = list(map(int, input().split()))


pos = []
neg = []
for a in A:
    a -= K
    if a >= 0:
        pos.append(a)
    else:
        neg.append(-a)


def calc_DP(X):
    dp = [0] * (U + 1)
    dp[0] = 1
    for p in X:
        for i in reversed(range(p, U + 1)):
            dp[i] += dp[i - p]
            dp[i] %= mod
    dp[0] -= 1
    return dp


pos = calc_DP(pos)
neg = calc_DP(neg)
for i in range(1, U + 1):
    neg[i] += neg[i - 1]
    neg[i] %= mod

ans = sum(pos) % mod
for i, v in enumerate(pos):
    ans += v * neg[i]
    ans %= mod
print(ans)
0