結果

問題 No.269 見栄っ張りの募金活動
ユーザー takakintakakin
提出日時 2020-05-11 22:17:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 659 ms / 5,000 ms
コード長 650 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,572 KB
実行使用メモリ 8,868 KB
最終ジャッジ日時 2023-09-26 12:35:16
合計ジャッジ時間 3,199 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,748 KB
testcase_01 AC 16 ms
7,772 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 35 ms
7,716 KB
testcase_04 AC 244 ms
8,760 KB
testcase_05 AC 16 ms
7,840 KB
testcase_06 AC 15 ms
7,788 KB
testcase_07 AC 659 ms
8,708 KB
testcase_08 AC 15 ms
7,788 KB
testcase_09 AC 15 ms
7,852 KB
testcase_10 AC 15 ms
7,756 KB
testcase_11 AC 61 ms
8,644 KB
testcase_12 AC 16 ms
7,788 KB
testcase_13 AC 88 ms
8,320 KB
testcase_14 AC 23 ms
8,868 KB
testcase_15 AC 81 ms
8,504 KB
testcase_16 AC 16 ms
7,800 KB
testcase_17 AC 15 ms
7,916 KB
testcase_18 AC 238 ms
8,360 KB
testcase_19 AC 78 ms
8,224 KB
testcase_20 AC 27 ms
8,120 KB
testcase_21 AC 27 ms
8,724 KB
testcase_22 AC 56 ms
8,156 KB
testcase_23 AC 21 ms
7,764 KB
testcase_24 AC 35 ms
8,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,s,k=map(int,input().split())
mod=10**9+7
s-=n*(n-1)//2*k
if s<0:
  print(0)
else:
  DP=[1]*(s+1) #n=1の場合にi円払う場合の数をDP[i]とする
  for i in range(2,n+1): #配列を使いまわして先頭に人を追加して人数を増やしていく
    for j in range(i,s+1): #金額が小さいほうから更新、追加した人が0円の場合と1円以上の場合の和になる
      DP[j]=(DP[j]+DP[j-i])%mod #1円以上の場合はDP[j-k*i]のkにわたる和になるが、既に更新されており和になっているのでそのまま足せばOK
  print(DP[s])
0