結果

問題 No.269 見栄っ張りの募金活動
ユーザー lemondolemondo
提出日時 2020-11-01 17:55:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 534 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 92,024 KB
最終ジャッジ日時 2023-09-29 11:18:26
合計ジャッジ時間 4,269 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,300 KB
testcase_01 AC 69 ms
71,300 KB
testcase_02 AC 68 ms
71,552 KB
testcase_03 AC 77 ms
76,004 KB
testcase_04 AC 93 ms
81,964 KB
testcase_05 AC 74 ms
76,208 KB
testcase_06 AC 70 ms
71,200 KB
testcase_07 AC 111 ms
92,024 KB
testcase_08 AC 70 ms
71,616 KB
testcase_09 AC 69 ms
71,108 KB
testcase_10 AC 69 ms
71,292 KB
testcase_11 AC 78 ms
76,200 KB
testcase_12 AC 70 ms
71,252 KB
testcase_13 AC 79 ms
76,056 KB
testcase_14 AC 76 ms
76,732 KB
testcase_15 AC 77 ms
75,980 KB
testcase_16 AC 70 ms
71,352 KB
testcase_17 AC 69 ms
71,264 KB
testcase_18 AC 85 ms
76,008 KB
testcase_19 AC 81 ms
76,280 KB
testcase_20 AC 75 ms
76,168 KB
testcase_21 AC 76 ms
76,084 KB
testcase_22 AC 78 ms
76,056 KB
testcase_23 AC 73 ms
75,960 KB
testcase_24 AC 76 ms
76,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, S, K = mapint()
mod = 10**9 + 7
if ((N - 1)*N//2)*K > S:
    print(0)
    exit()
else:
    S -= ((N - 1)*N//2)*K

# dp[i][j] j の i 分割
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for j in range(S+1):
        if j-i>=0:
            dp[i][j] = dp[i][j-i] + dp[i-1][j]
        else:
            dp[i][j] = dp[i-1][j]
        dp[i][j] %= mod
print(dp[-1][-1])
0