結果

問題 No.801 エレベーター
ユーザー tktk_snsn
提出日時 2020-12-09 21:42:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 360 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,792 KB
実行使用メモリ 83,372 KB
最終ジャッジ日時 2024-09-19 04:24:05
合計ジャッジ時間 7,865 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
mod = 10**9+7

n, m, k = map(int, input().split())
LR = tuple(tuple(map(int, input().split())) for _ in range(m))

dp = [1] * (n + 2)
dp[0] = 0

for _ in range(k):
    newDP = [0] * (n + 2)
    for l, r in LR:
        cnt = dp[r] - dp[l - 1]
        newDP[l] += cnt
        newDP[r + 1] -= cnt
    dp = list(accumulate(newDP))
    dp = list(accumulate(dp))
    for i in range(len(dp)):
        dp[i] %= mod

print((dp[n] - dp[n - 1]) % mod)
0