結果

問題 No.1011 Infinite Stairs
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-22 01:17:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,180 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 492,212 KB
最終ジャッジ日時 2023-09-24 11:07:44
合計ジャッジ時間 7,963 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,400 KB
testcase_01 AC 71 ms
71,572 KB
testcase_02 AC 103 ms
81,896 KB
testcase_03 AC 784 ms
368,964 KB
testcase_04 AC 196 ms
125,904 KB
testcase_05 AC 1,180 ms
492,212 KB
testcase_06 AC 75 ms
71,452 KB
testcase_07 AC 93 ms
78,428 KB
testcase_08 AC 72 ms
71,300 KB
testcase_09 AC 78 ms
76,244 KB
testcase_10 AC 88 ms
77,756 KB
testcase_11 AC 219 ms
135,736 KB
testcase_12 AC 85 ms
76,232 KB
testcase_13 AC 166 ms
114,064 KB
testcase_14 AC 80 ms
76,604 KB
testcase_15 AC 197 ms
124,948 KB
testcase_16 AC 569 ms
266,468 KB
testcase_17 AC 125 ms
92,900 KB
testcase_18 AC 389 ms
222,260 KB
testcase_19 AC 84 ms
76,416 KB
testcase_20 AC 80 ms
76,204 KB
testcase_21 AC 209 ms
135,448 KB
testcase_22 AC 318 ms
186,944 KB
testcase_23 AC 234 ms
153,796 KB
testcase_24 AC 242 ms
152,816 KB
testcase_25 AC 344 ms
197,692 KB
testcase_26 AC 132 ms
96,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d, k = map(int, input().split())
mod = 10**9+7

dp = [[0]*(k+1) for i in range(n+1)]
dp[0][0] = 1

from itertools import accumulate

for i in range(n):
    cum = [0]*(k+2)
    for j in range(k):
        cum[j+1] += dp[i][j]%mod
        if j+d <= k:
            cum[j+d+1] -= dp[i][j]%mod
        else:
            cum[-1] -= dp[i][j]%mod
    cum = list(accumulate(cum))
    dp[i+1] = cum[0:k+2]
print(dp[n][k]%mod)
0