結果

問題 No.801 エレベーター
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-29 15:19:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 597 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 79,468 KB
最終ジャッジ日時 2023-09-08 00:59:12
合計ジャッジ時間 12,231 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,640 KB
testcase_01 AC 70 ms
71,532 KB
testcase_02 AC 71 ms
71,216 KB
testcase_03 AC 85 ms
76,052 KB
testcase_04 AC 87 ms
76,500 KB
testcase_05 AC 88 ms
76,492 KB
testcase_06 AC 88 ms
76,156 KB
testcase_07 AC 87 ms
76,500 KB
testcase_08 AC 86 ms
76,228 KB
testcase_09 AC 87 ms
76,316 KB
testcase_10 AC 87 ms
76,380 KB
testcase_11 AC 86 ms
76,476 KB
testcase_12 AC 89 ms
76,380 KB
testcase_13 AC 589 ms
79,408 KB
testcase_14 AC 583 ms
79,340 KB
testcase_15 AC 588 ms
79,412 KB
testcase_16 AC 585 ms
79,152 KB
testcase_17 AC 582 ms
79,176 KB
testcase_18 AC 586 ms
79,468 KB
testcase_19 AC 592 ms
79,180 KB
testcase_20 AC 597 ms
79,292 KB
testcase_21 AC 597 ms
79,396 KB
testcase_22 AC 597 ms
79,436 KB
testcase_23 AC 586 ms
79,308 KB
testcase_24 AC 575 ms
79,284 KB
testcase_25 AC 591 ms
79,360 KB
testcase_26 AC 596 ms
79,160 KB
testcase_27 AC 581 ms
79,252 KB
testcase_28 AC 572 ms
79,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def main3(n,m,k,lr):
  mod=10**9+7
  dp=[0]*(n+1)
  dp[1]=1
  for _ in range(k):
    sdp=[0]
    for x in dp:sdp.append((sdp[-1]+x)%mod)
    ndp=[0]*(n+1)
    for l,r in lr:
      tmp=sdp[r+1]-sdp[l]
      ndp[l]+=tmp
      if r!=n:
        ndp[r+1]-=tmp
    for i in range(n):ndp[i+1]=(ndp[i+1]+ndp[i])%mod
    dp=ndp
  return dp[n]

if __name__=='__main__':
  n,m,k=map(int,input().split())
  lr=[list(map(int,input().split())) for _ in range(m)]
  ret=main3(n,m,k,lr)
  print(ret)
0