結果

問題 No.269 見栄っ張りの募金活動
ユーザー toshiconnertoshiconner
提出日時 2023-08-23 19:41:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 383 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 91,948 KB
最終ジャッジ日時 2023-08-23 19:41:38
合計ジャッジ時間 3,718 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,276 KB
testcase_01 AC 72 ms
71,060 KB
testcase_02 AC 71 ms
71,248 KB
testcase_03 AC 81 ms
76,284 KB
testcase_04 AC 90 ms
81,960 KB
testcase_05 AC 74 ms
75,904 KB
testcase_06 AC 72 ms
71,272 KB
testcase_07 AC 108 ms
91,948 KB
testcase_08 AC 74 ms
71,328 KB
testcase_09 AC 71 ms
71,240 KB
testcase_10 AC 73 ms
71,376 KB
testcase_11 AC 79 ms
76,088 KB
testcase_12 AC 71 ms
71,228 KB
testcase_13 AC 81 ms
76,220 KB
testcase_14 AC 76 ms
76,620 KB
testcase_15 AC 80 ms
75,960 KB
testcase_16 AC 71 ms
71,272 KB
testcase_17 AC 71 ms
71,544 KB
testcase_18 AC 88 ms
76,104 KB
testcase_19 AC 81 ms
76,240 KB
testcase_20 AC 81 ms
76,060 KB
testcase_21 AC 78 ms
76,196 KB
testcase_22 AC 78 ms
76,260 KB
testcase_23 AC 75 ms
75,772 KB
testcase_24 AC 77 ms
75,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, S, K = [int(x) for x in input().split()]
mod = 10**9 + 7

M = S - K * N * (N - 1) // 2

if M < 0:
    print(0)
    exit()

dp = [[0]*(M + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i in range(1, N + 1):
    for j in range(M + 1):
        if j - i >= 0:
            dp[i][j] = (dp[i - 1][j] + dp[i][j - i]) % mod
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[N][M])
0