結果

問題 No.269 見栄っ張りの募金活動
ユーザー takin6takin6
提出日時 2020-05-28 14:08:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 512 ms / 5,000 ms
コード長 358 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 88,960 KB
最終ジャッジ日時 2024-04-21 05:37:26
合計ジャッジ時間 2,682 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 45 ms
12,800 KB
testcase_04 AC 204 ms
38,016 KB
testcase_05 AC 28 ms
10,624 KB
testcase_06 AC 28 ms
10,752 KB
testcase_07 AC 512 ms
88,960 KB
testcase_08 AC 28 ms
10,624 KB
testcase_09 AC 26 ms
10,880 KB
testcase_10 AC 27 ms
10,752 KB
testcase_11 AC 61 ms
16,256 KB
testcase_12 AC 28 ms
10,624 KB
testcase_13 AC 81 ms
19,456 KB
testcase_14 AC 33 ms
11,776 KB
testcase_15 AC 77 ms
18,432 KB
testcase_16 AC 28 ms
10,752 KB
testcase_17 AC 28 ms
10,752 KB
testcase_18 AC 197 ms
37,248 KB
testcase_19 AC 77 ms
18,432 KB
testcase_20 AC 35 ms
12,032 KB
testcase_21 AC 36 ms
12,288 KB
testcase_22 AC 58 ms
15,488 KB
testcase_23 AC 31 ms
11,264 KB
testcase_24 AC 40 ms
12,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def pnk(S,N):
  mod = 10**9+7
  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

  return dp[-1][-1]

N,S,K = map(int,input().split())
S = S - (N*(N-1)//2)*K
if S < 0:
  print(0)
else:
  print(pnk(S,N))
0