結果

問題 No.269 見栄っ張りの募金活動
ユーザー tmg_dayotmg_dayo
提出日時 2019-09-24 22:17:17
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 649 ms / 5,000 ms
コード長 510 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 89,256 KB
最終ジャッジ日時 2023-10-19 16:02:34
合計ジャッジ時間 3,185 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,164 KB
testcase_01 AC 29 ms
10,164 KB
testcase_02 AC 29 ms
10,164 KB
testcase_03 AC 46 ms
12,356 KB
testcase_04 AC 243 ms
38,440 KB
testcase_05 AC 29 ms
10,268 KB
testcase_06 AC 29 ms
10,164 KB
testcase_07 AC 649 ms
89,256 KB
testcase_08 AC 29 ms
10,168 KB
testcase_09 AC 31 ms
10,164 KB
testcase_10 AC 29 ms
10,164 KB
testcase_11 AC 80 ms
16,796 KB
testcase_12 AC 29 ms
10,164 KB
testcase_13 AC 100 ms
19,484 KB
testcase_14 AC 47 ms
12,384 KB
testcase_15 AC 95 ms
18,692 KB
testcase_16 AC 29 ms
10,164 KB
testcase_17 AC 29 ms
10,164 KB
testcase_18 AC 241 ms
37,436 KB
testcase_19 AC 92 ms
18,164 KB
testcase_20 AC 43 ms
11,968 KB
testcase_21 AC 49 ms
12,616 KB
testcase_22 AC 70 ms
15,364 KB
testcase_23 AC 34 ms
10,772 KB
testcase_24 AC 53 ms
13,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n,s,k=map(int,input().split())
    s=s-(k*n*(n-1))//2
    M=10**9+7
    if s<0:
        print(0)
    else:
        dp=[[1]*n for _ in [0]*(s+1)]
        for i in range(1,s+1):
            for j in range(n):
                if j==0:
                    dp[i][j]=dp[i-1][j]
                elif i-j-1<0:
                    dp[i][j]=dp[i][j-1]
                else:
                    dp[i][j]=(dp[i][j-1]+dp[i-j-1][j])%M        
        print(dp[s][n-1])
    
if __name__ == '__main__':
	main()
0