結果

問題 No.1011 Infinite Stairs
ユーザー terasaterasa
提出日時 2022-05-31 13:58:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,054 ms / 2,000 ms
コード長 1,222 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 486,908 KB
最終ジャッジ日時 2023-10-21 00:37:43
合計ジャッジ時間 6,900 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,776 KB
testcase_01 AC 47 ms
55,776 KB
testcase_02 AC 77 ms
73,772 KB
testcase_03 AC 666 ms
340,948 KB
testcase_04 AC 361 ms
111,708 KB
testcase_05 AC 1,054 ms
486,908 KB
testcase_06 AC 106 ms
55,780 KB
testcase_07 AC 70 ms
70,320 KB
testcase_08 AC 46 ms
55,780 KB
testcase_09 AC 54 ms
64,080 KB
testcase_10 AC 66 ms
68,272 KB
testcase_11 AC 208 ms
133,096 KB
testcase_12 AC 66 ms
68,272 KB
testcase_13 AC 154 ms
110,580 KB
testcase_14 AC 61 ms
66,176 KB
testcase_15 AC 171 ms
111,868 KB
testcase_16 AC 498 ms
258,752 KB
testcase_17 AC 111 ms
88,740 KB
testcase_18 AC 312 ms
180,196 KB
testcase_19 AC 64 ms
68,272 KB
testcase_20 AC 61 ms
66,172 KB
testcase_21 AC 164 ms
113,776 KB
testcase_22 AC 265 ms
160,072 KB
testcase_23 AC 182 ms
122,912 KB
testcase_24 AC 193 ms
127,528 KB
testcase_25 AC 277 ms
165,584 KB
testcase_26 AC 112 ms
88,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


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

dp = [[0 for _ in range(K + 1)] for _ in range(N + 1)]
S = [[0 for _ in range(K + 1)] for _ in range(N + 1)]
dp[0][0] = 1
for j in range(K + 1):
    S[0][j] = 1

for i in range(1, N + 1):
    for j in range(1, K + 1):
        l = max(j - d, 0)
        r = max(j - 1, 0)
        dp[i][j] = (S[i - 1][r] - (S[i - 1][l - 1] if l > 0 else 0)) % mod
        S[i][j] = (S[i][j - 1] + dp[i][j]) % mod
print(dp[N][K])
0