結果

問題 No.1011 Infinite Stairs
ユーザー AEnAEn
提出日時 2022-05-17 15:41:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 672 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 86,656 KB
実行使用メモリ 288,776 KB
最終ジャッジ日時 2023-10-13 13:32:23
合計ジャッジ時間 5,726 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
70,988 KB
testcase_01 AC 60 ms
71,104 KB
testcase_02 AC 81 ms
76,476 KB
testcase_03 AC 464 ms
215,804 KB
testcase_04 AC 157 ms
92,904 KB
testcase_05 AC 672 ms
288,776 KB
testcase_06 AC 59 ms
71,164 KB
testcase_07 AC 77 ms
76,380 KB
testcase_08 AC 59 ms
71,272 KB
testcase_09 AC 67 ms
75,964 KB
testcase_10 AC 74 ms
76,140 KB
testcase_11 AC 166 ms
93,000 KB
testcase_12 AC 73 ms
76,232 KB
testcase_13 AC 132 ms
92,616 KB
testcase_14 AC 69 ms
76,132 KB
testcase_15 AC 140 ms
93,020 KB
testcase_16 AC 374 ms
174,344 KB
testcase_17 AC 106 ms
85,424 KB
testcase_18 AC 236 ms
132,804 KB
testcase_19 AC 72 ms
76,292 KB
testcase_20 AC 70 ms
76,064 KB
testcase_21 AC 144 ms
99,404 KB
testcase_22 AC 227 ms
122,356 KB
testcase_23 AC 154 ms
103,964 KB
testcase_24 AC 157 ms
106,064 KB
testcase_25 AC 220 ms
125,540 KB
testcase_26 AC 106 ms
86,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate

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

dp = [[0]*(K+2) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for j in range(K+1):
        if dp[i-1][j] > 0 and j+1<=K:
            dp[i][j+1] += dp[i-1][j]
            dp[i][min(j+d+1, K+1)] -= dp[i-1][j]
    for k in range(1,K+1):
        dp[i][k] += dp[i][k-1]
        dp[i][k] %= mod
print(dp[-1][-2])
0