結果

問題 No.1011 Infinite Stairs
ユーザー universatouniversato
提出日時 2020-03-22 12:59:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 726 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 933 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 289,448 KB
最終ジャッジ日時 2023-09-24 11:07:57
合計ジャッジ時間 6,184 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,300 KB
testcase_01 AC 71 ms
71,152 KB
testcase_02 AC 96 ms
76,472 KB
testcase_03 AC 507 ms
216,372 KB
testcase_04 AC 156 ms
92,880 KB
testcase_05 AC 726 ms
289,448 KB
testcase_06 AC 72 ms
71,240 KB
testcase_07 AC 87 ms
76,028 KB
testcase_08 AC 72 ms
71,300 KB
testcase_09 AC 77 ms
75,844 KB
testcase_10 AC 86 ms
76,068 KB
testcase_11 AC 168 ms
92,920 KB
testcase_12 AC 84 ms
76,200 KB
testcase_13 AC 140 ms
92,768 KB
testcase_14 AC 81 ms
76,076 KB
testcase_15 AC 157 ms
93,124 KB
testcase_16 AC 382 ms
174,160 KB
testcase_17 AC 106 ms
76,404 KB
testcase_18 AC 254 ms
132,416 KB
testcase_19 AC 83 ms
76,180 KB
testcase_20 AC 81 ms
76,096 KB
testcase_21 AC 153 ms
99,028 KB
testcase_22 AC 229 ms
122,364 KB
testcase_23 AC 165 ms
103,608 KB
testcase_24 AC 174 ms
106,156 KB
testcase_25 AC 236 ms
124,900 KB
testcase_26 AC 106 ms
76,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input():
    return sys.stdin.readline()[:-1]

mod = 10 ** 9 + 7

n,d,k = map(int,input().split())

w = min(d*n+1,k+1)
dp = [[0] * w for i in range(n+1) ]
dp[0][0] = 1
s = [0] * w

for i in range(n):
    # for j in range(d*n,0,-1):
    # s = [0] * w
    s[0] = dp[i][0]
    # print(s)
    for j in range(w-1):
        s[j+1] = (s[j] + dp[i][j+1]) % mod
    
    for j in range(w-1):
        dp[i+1][j+1] = s[j] % mod
        if 0 <= j-d:
            dp[i+1][j+1] = (dp[i+1][j+1] - s[j-d]) % mod

# print(dp)
print(dp[n][k] % mod)
0