結果

問題 No.801 エレベーター
ユーザー rlangevinrlangevin
提出日時 2023-09-21 08:55:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 368 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 78,840 KB
最終ジャッジ日時 2023-09-21 08:55:25
合計ジャッジ時間 8,784 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,004 KB
testcase_01 AC 67 ms
71,140 KB
testcase_02 AC 68 ms
71,000 KB
testcase_03 AC 86 ms
76,868 KB
testcase_04 AC 86 ms
76,736 KB
testcase_05 AC 93 ms
76,616 KB
testcase_06 AC 86 ms
76,664 KB
testcase_07 AC 86 ms
76,252 KB
testcase_08 AC 86 ms
76,724 KB
testcase_09 AC 86 ms
76,704 KB
testcase_10 AC 87 ms
76,512 KB
testcase_11 AC 91 ms
76,696 KB
testcase_12 AC 91 ms
76,616 KB
testcase_13 AC 367 ms
78,660 KB
testcase_14 AC 366 ms
78,660 KB
testcase_15 AC 355 ms
78,768 KB
testcase_16 AC 356 ms
78,712 KB
testcase_17 AC 365 ms
78,632 KB
testcase_18 AC 355 ms
78,436 KB
testcase_19 AC 356 ms
78,460 KB
testcase_20 AC 364 ms
78,564 KB
testcase_21 AC 364 ms
78,644 KB
testcase_22 AC 364 ms
78,496 KB
testcase_23 AC 365 ms
78,840 KB
testcase_24 AC 353 ms
78,456 KB
testcase_25 AC 358 ms
78,508 KB
testcase_26 AC 368 ms
78,620 KB
testcase_27 AC 361 ms
78,604 KB
testcase_28 AC 364 ms
78,628 KB
権限があれば一括ダウンロードができます

ソースコード

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