結果

問題 No.801 エレベーター
ユーザー vwxyzvwxyz
提出日時 2022-10-26 14:13:33
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 951 ms / 2,000 ms
コード長 2,643 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 96,556 KB
最終ジャッジ日時 2023-09-17 07:09:45
合計ジャッジ時間 20,272 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 245 ms
91,428 KB
testcase_01 AC 243 ms
91,340 KB
testcase_02 AC 242 ms
91,404 KB
testcase_03 AC 278 ms
94,976 KB
testcase_04 AC 280 ms
94,948 KB
testcase_05 AC 282 ms
95,332 KB
testcase_06 AC 285 ms
94,892 KB
testcase_07 AC 287 ms
95,296 KB
testcase_08 AC 288 ms
95,032 KB
testcase_09 AC 280 ms
95,292 KB
testcase_10 AC 284 ms
94,964 KB
testcase_11 AC 286 ms
95,036 KB
testcase_12 AC 275 ms
94,896 KB
testcase_13 AC 936 ms
96,188 KB
testcase_14 AC 937 ms
96,184 KB
testcase_15 AC 931 ms
95,960 KB
testcase_16 AC 934 ms
96,388 KB
testcase_17 AC 938 ms
96,028 KB
testcase_18 AC 936 ms
96,556 KB
testcase_19 AC 941 ms
96,448 KB
testcase_20 AC 936 ms
96,476 KB
testcase_21 AC 934 ms
96,368 KB
testcase_22 AC 939 ms
96,156 KB
testcase_23 AC 940 ms
96,152 KB
testcase_24 AC 939 ms
96,468 KB
testcase_25 AC 941 ms
96,192 KB
testcase_26 AC 951 ms
96,200 KB
testcase_27 AC 945 ms
96,136 KB
testcase_28 AC 914 ms
96,144 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,M,K=map(int,readline().split())
L,R=[],[]
for _ in range(M):
    l,r=map(int,readline().split())
    l-=1
    L.append(l)
    R.append(r)
dp=[0]*N
dp[0]=1
mod=10**9+7
for k in range(K):
    prev=Cumsum(dp,mod=mod)
    imos=[0]*(N+1)
    for l,r in zip(L,R):
        imos[l]+=prev[l:r]
        imos[r]-=prev[l:r]
    for i in range(1,N+1):
        imos[i]+=imos[i-1]
        imos[i]%=mod
    dp=imos[:N]
ans=dp[N-1]
print(ans)
0