結果

問題 No.1011 Infinite Stairs
ユーザー vwxyzvwxyz
提出日時 2022-10-26 12:36:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,640 ms / 2,000 ms
コード長 2,402 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 261,916 KB
最終ジャッジ日時 2023-09-17 05:46:34
合計ジャッジ時間 18,680 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 268 ms
91,004 KB
testcase_01 AC 261 ms
91,236 KB
testcase_02 AC 316 ms
95,044 KB
testcase_03 AC 1,212 ms
261,436 KB
testcase_04 AC 1,639 ms
260,832 KB
testcase_05 AC 1,640 ms
260,520 KB
testcase_06 AC 258 ms
91,188 KB
testcase_07 AC 442 ms
143,500 KB
testcase_08 AC 261 ms
91,136 KB
testcase_09 AC 273 ms
94,668 KB
testcase_10 AC 314 ms
94,948 KB
testcase_11 AC 862 ms
260,572 KB
testcase_12 AC 296 ms
94,608 KB
testcase_13 AC 587 ms
184,940 KB
testcase_14 AC 303 ms
95,052 KB
testcase_15 AC 480 ms
153,192 KB
testcase_16 AC 1,255 ms
261,916 KB
testcase_17 AC 1,323 ms
260,352 KB
testcase_18 AC 696 ms
218,708 KB
testcase_19 AC 284 ms
94,420 KB
testcase_20 AC 306 ms
94,800 KB
testcase_21 AC 502 ms
160,680 KB
testcase_22 AC 1,158 ms
260,756 KB
testcase_23 AC 492 ms
158,008 KB
testcase_24 AC 485 ms
154,872 KB
testcase_25 AC 693 ms
217,404 KB
testcase_26 AC 375 ms
124,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
class Cumsum:
    def __init__(self,lst,mod=0):
        self.N=len(lst)
        self.mod=mod
        self.cumsum=[0]*(self.N+1)
        self.cumsum[0]=0
        for i in range(1,self.N+1):
            self.cumsum[i]=self.cumsum[i-1]+lst[i-1]
            if self.mod:
                self.cumsum[i]%=self.mod

    def __getitem__(self,i):
        if type(i)==int:
            if 0<=i<self.N:
                a,b=i,i+1
            elif -self.N<=i<0:
                a,b=i+self.N,i+self.N+1
            else:
                raise IndexError('list index out of range')
        else:
            a,b=i.start,i.stop
            if a==None or a<-self.N:
                a=0
            elif self.N<=a:
                a=self.N
            elif a<0:
                a+=self.N
            if b==None or self.N<=b:
                b=self.N
            elif b<-self.N:
                b=0
            elif b<0:
                b+=self.N
        s=self.cumsum[b]-self.cumsum[a]
        if self.mod:
            s%=self.mod
        return s

    def __setitem__(self,i,x):
        if -self.N<=i<0:
            i+=self.N
        elif not 0<=i<self.N:
            raise IndexError('list index out of range')
        self.cumsum[i+1]=self.cumsum[i]+x
        if self.mod:
            self.cumsum[i+1]%=self.mod

    def __str__(self):
        lst=[self.cumsum[i+1]-self.cumsum[i] for i in range(self.N)]
        if self.mod:
            for i in range(self.N):
                lst[i]%=self.mod
        return "["+", ".join(map(str,lst))+"]"

N,D,K=map(int,readline().split())
dp=[0]*(N*D+1)
dp[0]=1
mod=10**9+7
for n in range(N):
    prev=Cumsum(dp,mod=mod)
    dp=[prev[max(0,i-D):i] for i in range(N*D+1)]
ans=dp[K]
print(ans)
0