結果

問題 No.269 見栄っ張りの募金活動
ユーザー lloyzlloyz
提出日時 2023-08-29 07:17:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 92,224 KB
最終ジャッジ日時 2023-08-29 07:17:35
合計ジャッジ時間 4,361 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,516 KB
testcase_01 AC 74 ms
71,312 KB
testcase_02 AC 75 ms
71,460 KB
testcase_03 AC 91 ms
76,080 KB
testcase_04 AC 98 ms
81,932 KB
testcase_05 AC 98 ms
76,392 KB
testcase_06 AC 76 ms
71,300 KB
testcase_07 AC 121 ms
92,224 KB
testcase_08 AC 75 ms
71,336 KB
testcase_09 AC 75 ms
71,308 KB
testcase_10 AC 75 ms
71,404 KB
testcase_11 AC 84 ms
76,104 KB
testcase_12 AC 76 ms
71,632 KB
testcase_13 AC 85 ms
76,324 KB
testcase_14 AC 83 ms
76,724 KB
testcase_15 AC 84 ms
76,456 KB
testcase_16 AC 76 ms
71,352 KB
testcase_17 AC 83 ms
71,148 KB
testcase_18 AC 94 ms
76,096 KB
testcase_19 AC 88 ms
76,452 KB
testcase_20 AC 82 ms
76,312 KB
testcase_21 AC 86 ms
76,236 KB
testcase_22 AC 88 ms
76,092 KB
testcase_23 AC 81 ms
76,364 KB
testcase_24 AC 83 ms
76,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

DP = [[0 for _ in range(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