結果

問題 No.1011 Infinite Stairs
ユーザー rlangevinrlangevin
提出日時 2023-01-31 23:17:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 595 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 260,552 KB
最終ジャッジ日時 2023-09-13 15:00:13
合計ジャッジ時間 8,430 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,404 KB
testcase_01 AC 69 ms
71,244 KB
testcase_02 AC 94 ms
77,264 KB
testcase_03 AC 456 ms
259,920 KB
testcase_04 AC 595 ms
259,456 KB
testcase_05 AC 595 ms
259,684 KB
testcase_06 AC 70 ms
71,208 KB
testcase_07 AC 146 ms
125,124 KB
testcase_08 AC 71 ms
71,476 KB
testcase_09 AC 76 ms
76,228 KB
testcase_10 AC 97 ms
77,380 KB
testcase_11 AC 314 ms
251,048 KB
testcase_12 AC 87 ms
76,176 KB
testcase_13 AC 204 ms
166,816 KB
testcase_14 AC 88 ms
76,384 KB
testcase_15 AC 162 ms
135,028 KB
testcase_16 AC 471 ms
260,552 KB
testcase_17 AC 496 ms
259,916 KB
testcase_18 AC 248 ms
200,544 KB
testcase_19 AC 85 ms
76,104 KB
testcase_20 AC 92 ms
77,592 KB
testcase_21 AC 172 ms
142,516 KB
testcase_22 AC 429 ms
259,784 KB
testcase_23 AC 166 ms
139,328 KB
testcase_24 AC 163 ms
136,392 KB
testcase_25 AC 246 ms
199,508 KB
testcase_26 AC 124 ms
105,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, d, K = map(int, input().split())
M = d * N
mod = 10 ** 9 + 7
pre = [0] * (M + 1)
preAc = [0] * (M + 2)
pre[0] = 1
for i in range(M + 1):
    preAc[i + 1] = preAc[i] + pre[i]
    
for i in range(N):
    dp = [0] * (M + 1)
    Ac = [0] * (M + 2)
    for j in range(1, M + 1):
        dp[j] = preAc[j] - preAc[max(0, j - d)]
        Ac[j + 1] = Ac[j] + dp[j]
        dp[j] %= mod
        Ac[j + 1] %= mod
        
    dp, pre = pre, dp
    Ac, preAc = preAc, Ac
print(pre[K])
0