結果

問題 No.269 見栄っ張りの募金活動
ユーザー tmsausatmsausa
提出日時 2018-11-14 20:36:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 394 bytes
コンパイル時間 887 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 76,460 KB
最終ジャッジ日時 2023-09-23 01:36:17
合計ジャッジ時間 3,834 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,268 KB
testcase_01 AC 73 ms
71,528 KB
testcase_02 AC 71 ms
71,480 KB
testcase_03 AC 78 ms
75,996 KB
testcase_04 AC 82 ms
76,248 KB
testcase_05 AC 76 ms
76,092 KB
testcase_06 AC 73 ms
71,124 KB
testcase_07 AC 85 ms
76,460 KB
testcase_08 AC 74 ms
71,348 KB
testcase_09 AC 73 ms
71,260 KB
testcase_10 AC 73 ms
71,352 KB
testcase_11 AC 78 ms
76,052 KB
testcase_12 AC 71 ms
71,240 KB
testcase_13 AC 79 ms
75,992 KB
testcase_14 AC 76 ms
75,964 KB
testcase_15 AC 81 ms
76,172 KB
testcase_16 AC 74 ms
71,072 KB
testcase_17 AC 73 ms
71,232 KB
testcase_18 AC 81 ms
75,956 KB
testcase_19 AC 80 ms
76,104 KB
testcase_20 AC 79 ms
76,304 KB
testcase_21 AC 79 ms
75,944 KB
testcase_22 AC 78 ms
76,224 KB
testcase_23 AC 77 ms
75,888 KB
testcase_24 AC 80 ms
75,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# time complexity: O()
# space complexity: O()

MOD = 10**9 + 7
N, S, K = map(int, input().split())

min_donation = (N - 1) * K * N // 2
if min_donation > S:
    print(0)
    exit(0)
elif min_donation == S:
    print(1)
    exit(0)

S -= min_donation

dp = [1] * (S + 1)
for i in range(2, N + 1):
    for j in range(i, S + 1):
        dp[j] = dp[j - i] + dp[j]
        dp[j] %= MOD
print(dp[S])
0