結果

問題 No.1011 Infinite Stairs
ユーザー FromBooskaFromBooska
提出日時 2023-03-21 21:12:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 842 ms / 2,000 ms
コード長 596 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 226,056 KB
最終ジャッジ日時 2023-10-18 18:35:37
合計ジャッジ時間 5,951 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,552 KB
testcase_01 AC 37 ms
53,552 KB
testcase_02 AC 67 ms
75,704 KB
testcase_03 AC 575 ms
174,248 KB
testcase_04 AC 135 ms
77,996 KB
testcase_05 AC 842 ms
226,056 KB
testcase_06 AC 38 ms
53,552 KB
testcase_07 AC 61 ms
75,416 KB
testcase_08 AC 38 ms
53,552 KB
testcase_09 AC 44 ms
60,344 KB
testcase_10 AC 53 ms
72,408 KB
testcase_11 AC 150 ms
79,252 KB
testcase_12 AC 53 ms
70,360 KB
testcase_13 AC 114 ms
77,904 KB
testcase_14 AC 47 ms
64,172 KB
testcase_15 AC 126 ms
78,416 KB
testcase_16 AC 429 ms
147,404 KB
testcase_17 AC 83 ms
75,808 KB
testcase_18 AC 268 ms
117,640 KB
testcase_19 AC 55 ms
70,360 KB
testcase_20 AC 49 ms
64,172 KB
testcase_21 AC 141 ms
91,348 KB
testcase_22 AC 226 ms
98,208 KB
testcase_23 AC 170 ms
107,412 KB
testcase_24 AC 169 ms
96,940 KB
testcase_25 AC 239 ms
104,480 KB
testcase_26 AC 87 ms
76,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# dp[i階][j回の移動]回数は当然TLEした
# 実験するとdの個数分だけの前行の和となる
# 累積sdpとするか

N, d, K = map(int, input().split())
dp = [0]*(K+1)
sdp = [1]*(K+2)
dp[0] = 1
sdp[0] = 0
mod = 10**9+7

#print(dp)
#print(sdp)

for i in range(1, N+1):
    new_dp =[0]*(K+1)
    for j in range(K+1):
        new_dp[j] = sdp[j]-sdp[max(0, j-d)]
        new_dp[j] %= mod
    dp = new_dp
    sdp = [0]
    temp = 0
    for j in range(K+1):
        temp += dp[j]
        temp %= mod
        sdp.append(temp)
    #print(dp)
    #print(sdp)

ans = dp[K]%mod
print(ans)
0