結果

問題 No.801 エレベーター
ユーザー rlangevin
提出日時 2023-09-21 08:55:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 292 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 77,424 KB
最終ジャッジ日時 2024-07-07 03:13:30
合計ジャッジ時間 6,087 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, M, K = map(int, input().split())
mod = 10 ** 9 + 7
L, R = [0] * M, [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())
    L[i] -= 1

pre = [0] * N
pre[0] = 1
for _ in range(K):
    Ac = [0] * (N + 1)
    dp = [0] * (N + 1)
    ndp = [0] * (N + 1)
    for i in range(N):
        Ac[i + 1] = Ac[i] + pre[i]
        Ac[i + 1] %= mod
    
    for i in range(M):
        dp[L[i]] += Ac[R[i]] - Ac[L[i]]
        dp[R[i]] -= Ac[R[i]] - Ac[L[i]]
        dp[L[i]] %= mod
        dp[R[i]] %= mod

    ndp[0] = dp[0]
    for i in range(N):
        ndp[i + 1] = ndp[i] + dp[i + 1]
        ndp[i + 1] %= mod

    ndp, pre = pre, ndp

print(pre[N - 1]%mod)
0