結果

問題 No.269 見栄っ張りの募金活動
ユーザー titiatitia
提出日時 2022-09-02 00:08:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 483 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 77,568 KB
最終ジャッジ日時 2024-04-27 00:11:28
合計ジャッジ時間 2,847 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,968 KB
testcase_01 AC 39 ms
51,584 KB
testcase_02 AC 51 ms
60,672 KB
testcase_03 AC 60 ms
63,616 KB
testcase_04 AC 76 ms
68,992 KB
testcase_05 AC 48 ms
59,136 KB
testcase_06 AC 40 ms
51,840 KB
testcase_07 AC 101 ms
77,568 KB
testcase_08 AC 41 ms
51,840 KB
testcase_09 AC 72 ms
69,888 KB
testcase_10 AC 52 ms
60,160 KB
testcase_11 AC 58 ms
62,720 KB
testcase_12 AC 69 ms
67,968 KB
testcase_13 AC 62 ms
64,000 KB
testcase_14 AC 52 ms
60,928 KB
testcase_15 AC 61 ms
63,744 KB
testcase_16 AC 68 ms
67,968 KB
testcase_17 AC 60 ms
63,744 KB
testcase_18 AC 82 ms
72,320 KB
testcase_19 AC 64 ms
65,024 KB
testcase_20 AC 57 ms
62,336 KB
testcase_21 AC 53 ms
61,568 KB
testcase_22 AC 58 ms
63,104 KB
testcase_23 AC 55 ms
62,080 KB
testcase_24 AC 55 ms
61,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,S,K=map(int,input().split())
DP=[0]*(S+1)
DP[S]=1

mod=10**9+7
for i in range(N):
    NDP=[0]*(S+1)
    rest=N-i
    for j in range(S+1):
        if i==0:
            if DP[j]!=0:
                NDP[j]+=DP[j]
        else:            
            if DP[j]!=0 and j-rest*K>=0:
                NDP[j-rest*K]+=DP[j]
                NDP[j-rest*K]%=mod

    for j in range(S,-1,-1):
        if j+rest<=S:
            NDP[j]+=NDP[j+rest]
            NDP[j]%=mod
    DP=NDP

print(DP[0])
0