結果

問題 No.269 見栄っ張りの募金活動
ユーザー こどこどこどこど
提出日時 2020-08-21 18:51:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 540 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 90,004 KB
最終ジャッジ日時 2023-08-05 07:16:05
合計ジャッジ時間 3,984 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,324 KB
testcase_01 AC 69 ms
71,416 KB
testcase_02 AC 70 ms
71,064 KB
testcase_03 AC 82 ms
76,604 KB
testcase_04 AC 89 ms
76,644 KB
testcase_05 AC 75 ms
76,344 KB
testcase_06 AC 69 ms
71,080 KB
testcase_07 AC 122 ms
90,004 KB
testcase_08 AC 69 ms
71,208 KB
testcase_09 AC 67 ms
71,580 KB
testcase_10 AC 69 ms
71,496 KB
testcase_11 AC 83 ms
76,564 KB
testcase_12 AC 71 ms
71,068 KB
testcase_13 AC 81 ms
76,328 KB
testcase_14 AC 81 ms
76,752 KB
testcase_15 AC 82 ms
76,460 KB
testcase_16 AC 69 ms
71,236 KB
testcase_17 AC 70 ms
71,248 KB
testcase_18 AC 90 ms
76,576 KB
testcase_19 AC 82 ms
76,600 KB
testcase_20 AC 80 ms
76,520 KB
testcase_21 AC 81 ms
76,940 KB
testcase_22 AC 81 ms
76,324 KB
testcase_23 AC 79 ms
76,356 KB
testcase_24 AC 81 ms
76,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def create_multi_list(init_val, *args):
    if len(args) == 1:
        return [init_val] * args[0]
    else:
        return [create_multi_list(init_val, *args[1:]) for _ in range(args[0])]

n, s, k = map(int, input().split())
mod = 10 ** 9 + 7
s = s - k * n * (n-1) // 2
if s < 0:
    print(0)
    quit()
dp = create_multi_list(0, s+1, n+1)
dp[0][0] = 1
for i in range(s+1):
    for j in range(n+1):
        if i >= j:
            dp[i][j] = (dp[i][j-1] + dp[i-j][j]) % mod
        else:
            dp[i][j] = dp[i][j-1]
print(dp[-1][-1])
0