結果

問題 No.1011 Infinite Stairs
ユーザー universatouniversato
提出日時 2020-03-22 00:32:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 700 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 883 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 289,192 KB
最終ジャッジ日時 2023-09-24 11:07:24
合計ジャッジ時間 5,876 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,276 KB
testcase_01 AC 68 ms
71,064 KB
testcase_02 AC 98 ms
76,316 KB
testcase_03 AC 492 ms
216,492 KB
testcase_04 AC 154 ms
92,728 KB
testcase_05 AC 700 ms
289,192 KB
testcase_06 AC 68 ms
71,176 KB
testcase_07 AC 84 ms
75,948 KB
testcase_08 AC 69 ms
71,076 KB
testcase_09 AC 74 ms
75,996 KB
testcase_10 AC 83 ms
76,068 KB
testcase_11 AC 160 ms
92,644 KB
testcase_12 AC 80 ms
76,048 KB
testcase_13 AC 136 ms
92,684 KB
testcase_14 AC 76 ms
76,004 KB
testcase_15 AC 146 ms
92,736 KB
testcase_16 AC 364 ms
173,940 KB
testcase_17 AC 100 ms
76,164 KB
testcase_18 AC 243 ms
132,408 KB
testcase_19 AC 83 ms
76,000 KB
testcase_20 AC 78 ms
76,084 KB
testcase_21 AC 144 ms
98,920 KB
testcase_22 AC 220 ms
122,476 KB
testcase_23 AC 160 ms
103,544 KB
testcase_24 AC 167 ms
105,760 KB
testcase_25 AC 221 ms
125,032 KB
testcase_26 AC 107 ms
76,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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