結果

問題 No.269 見栄っ張りの募金活動
ユーザー tai_yakitai_yaki
提出日時 2020-07-04 17:03:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,546 ms / 5,000 ms
コード長 357 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 11,872 KB
実行使用メモリ 88,392 KB
最終ジャッジ日時 2023-10-19 08:41:54
合計ジャッジ時間 5,887 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,100 KB
testcase_01 AC 30 ms
10,100 KB
testcase_02 AC 30 ms
10,100 KB
testcase_03 AC 75 ms
12,332 KB
testcase_04 AC 555 ms
37,392 KB
testcase_05 AC 32 ms
10,188 KB
testcase_06 AC 30 ms
10,112 KB
testcase_07 AC 1,546 ms
88,392 KB
testcase_08 AC 29 ms
10,100 KB
testcase_09 AC 29 ms
10,100 KB
testcase_10 AC 29 ms
10,100 KB
testcase_11 AC 150 ms
15,848 KB
testcase_12 AC 29 ms
10,100 KB
testcase_13 AC 202 ms
18,936 KB
testcase_14 AC 58 ms
11,196 KB
testcase_15 AC 184 ms
18,020 KB
testcase_16 AC 30 ms
10,100 KB
testcase_17 AC 29 ms
10,100 KB
testcase_18 AC 565 ms
36,976 KB
testcase_19 AC 180 ms
17,728 KB
testcase_20 AC 61 ms
11,472 KB
testcase_21 AC 67 ms
11,644 KB
testcase_22 AC 131 ms
15,044 KB
testcase_23 AC 42 ms
10,664 KB
testcase_24 AC 78 ms
12,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, s, k = map(int, input().split())
mod = 10 ** 9 + 7


s -= k * n * (n - 1) // 2
if s < 0:
    print(0)
    exit()

dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
dp[0][0] = 1

for i in range(1, n+1):
    for j in range(s+1):
        dp[i][j] += dp[i-1][j]
        if j >= i:
            dp[i][j] += dp[i][j-i]

        dp[i][j] %= mod

print(dp[n][s])
0