結果

問題 No.269 見栄っ張りの募金活動
ユーザー takakintakakin
提出日時 2020-05-11 21:59:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,396 ms / 5,000 ms
コード長 439 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 86,424 KB
最終ジャッジ日時 2023-09-26 12:10:39
合計ジャッジ時間 5,127 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,308 KB
testcase_01 AC 18 ms
8,280 KB
testcase_02 AC 18 ms
8,348 KB
testcase_03 AC 57 ms
10,588 KB
testcase_04 AC 481 ms
35,480 KB
testcase_05 AC 19 ms
8,540 KB
testcase_06 AC 19 ms
8,300 KB
testcase_07 AC 1,396 ms
86,424 KB
testcase_08 AC 19 ms
8,320 KB
testcase_09 AC 18 ms
8,416 KB
testcase_10 AC 18 ms
8,304 KB
testcase_11 AC 113 ms
14,048 KB
testcase_12 AC 18 ms
8,340 KB
testcase_13 AC 171 ms
17,044 KB
testcase_14 AC 33 ms
9,360 KB
testcase_15 AC 152 ms
16,128 KB
testcase_16 AC 18 ms
8,444 KB
testcase_17 AC 18 ms
8,352 KB
testcase_18 AC 485 ms
34,648 KB
testcase_19 AC 152 ms
15,912 KB
testcase_20 AC 39 ms
9,720 KB
testcase_21 AC 41 ms
9,768 KB
testcase_22 AC 107 ms
13,256 KB
testcase_23 AC 27 ms
8,912 KB
testcase_24 AC 54 ms
10,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,s,k=map(int,input().split())
mod=10**9+7
import copy
s-=n*(n-1)//2*k
if s<0:
  print(0)
else:
  DP=[[0]*(s+1) for _ in range(n+1)]
  for i in range(s+1):
    DP[1][i]=1
  for i in range(2,n+1):
    for j in range(s+1):
      if j-i>=0:
        DP[i][j]=DP[i-1][j]+DP[i][j-i]
        if DP[i][j]>mod:
          DP[i][j]%=mod
      else:
        DP[i][j]=DP[i-1][j]
  print(DP[n][s])
0