結果

問題 No.269 見栄っ張りの募金活動
ユーザー takin6takin6
提出日時 2020-05-18 14:14:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,046 ms / 5,000 ms
コード長 314 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 88,960 KB
最終ジャッジ日時 2024-04-09 21:28:17
合計ジャッジ時間 3,891 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 58 ms
12,928 KB
testcase_04 AC 392 ms
38,016 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 27 ms
10,752 KB
testcase_07 AC 1,046 ms
88,960 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 AC 27 ms
10,752 KB
testcase_10 AC 27 ms
10,880 KB
testcase_11 AC 100 ms
16,384 KB
testcase_12 AC 26 ms
10,752 KB
testcase_13 AC 138 ms
19,456 KB
testcase_14 AC 38 ms
11,776 KB
testcase_15 AC 138 ms
18,560 KB
testcase_16 AC 29 ms
10,880 KB
testcase_17 AC 27 ms
10,880 KB
testcase_18 AC 370 ms
37,248 KB
testcase_19 AC 125 ms
18,304 KB
testcase_20 AC 45 ms
12,032 KB
testcase_21 AC 43 ms
12,288 KB
testcase_22 AC 92 ms
15,744 KB
testcase_23 AC 36 ms
11,264 KB
testcase_24 AC 56 ms
13,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,s,k = map(int, input().split())
mod = 10**9+7
s -= (n*(n-1)//2)*k
if s < 0:
  print(0)
  exit()

dp = [ [1]*(s+1) for _ in range(n+1) ]

for i in range(2, n+1):
  for j in range(s+1):
    if j >= i:
      dp[i][j] = (dp[i-1][j] + dp[i][j-i]) % mod
    else:
      dp[i][j] = (dp[i-1][j]) % mod

print(dp[-1][-1])
0