結果

問題 No.269 見栄っ張りの募金活動
ユーザー こどこどこどこど
提出日時 2020-08-21 18:51:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 540 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,156 KB
実行使用メモリ 90,496 KB
最終ジャッジ日時 2024-04-23 05:14:33
合計ジャッジ時間 2,109 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,712 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 35 ms
51,840 KB
testcase_03 AC 49 ms
63,488 KB
testcase_04 AC 58 ms
71,040 KB
testcase_05 AC 42 ms
59,904 KB
testcase_06 AC 35 ms
52,608 KB
testcase_07 AC 99 ms
90,496 KB
testcase_08 AC 35 ms
52,740 KB
testcase_09 AC 33 ms
52,708 KB
testcase_10 AC 37 ms
52,980 KB
testcase_11 AC 47 ms
66,744 KB
testcase_12 AC 35 ms
52,132 KB
testcase_13 AC 46 ms
65,380 KB
testcase_14 AC 46 ms
66,752 KB
testcase_15 AC 47 ms
66,912 KB
testcase_16 AC 34 ms
53,496 KB
testcase_17 AC 33 ms
53,604 KB
testcase_18 AC 54 ms
71,148 KB
testcase_19 AC 45 ms
65,404 KB
testcase_20 AC 44 ms
64,352 KB
testcase_21 AC 43 ms
65,828 KB
testcase_22 AC 44 ms
64,316 KB
testcase_23 AC 40 ms
62,136 KB
testcase_24 AC 44 ms
65,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def create_multi_list(init_val, *args):
    if len(args) == 1:
        return [init_val] * args[0]
    else:
        return [create_multi_list(init_val, *args[1:]) for _ in range(args[0])]

n, s, k = map(int, input().split())
mod = 10 ** 9 + 7
s = s - k * n * (n-1) // 2
if s < 0:
    print(0)
    quit()
dp = create_multi_list(0, s+1, n+1)
dp[0][0] = 1
for i in range(s+1):
    for j in range(n+1):
        if i >= j:
            dp[i][j] = (dp[i][j-1] + dp[i-j][j]) % mod
        else:
            dp[i][j] = dp[i][j-1]
print(dp[-1][-1])
0