結果

問題 No.801 エレベーター
ユーザー 👑 rin204rin204
提出日時 2022-07-04 17:59:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 501 ms / 2,000 ms
コード長 531 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 80,928 KB
最終ジャッジ日時 2023-08-21 01:45:41
合計ジャッジ時間 11,077 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,516 KB
testcase_01 AC 69 ms
71,456 KB
testcase_02 AC 71 ms
71,468 KB
testcase_03 AC 91 ms
76,764 KB
testcase_04 AC 89 ms
76,876 KB
testcase_05 AC 90 ms
76,552 KB
testcase_06 AC 90 ms
76,544 KB
testcase_07 AC 90 ms
76,656 KB
testcase_08 AC 90 ms
76,384 KB
testcase_09 AC 91 ms
76,920 KB
testcase_10 AC 91 ms
76,364 KB
testcase_11 AC 91 ms
76,488 KB
testcase_12 AC 91 ms
76,588 KB
testcase_13 AC 488 ms
80,432 KB
testcase_14 AC 497 ms
80,764 KB
testcase_15 AC 496 ms
80,624 KB
testcase_16 AC 495 ms
80,760 KB
testcase_17 AC 492 ms
80,928 KB
testcase_18 AC 496 ms
80,568 KB
testcase_19 AC 497 ms
80,836 KB
testcase_20 AC 497 ms
80,724 KB
testcase_21 AC 501 ms
80,708 KB
testcase_22 AC 500 ms
80,612 KB
testcase_23 AC 446 ms
80,532 KB
testcase_24 AC 450 ms
80,560 KB
testcase_25 AC 460 ms
80,556 KB
testcase_26 AC 455 ms
80,816 KB
testcase_27 AC 448 ms
80,576 KB
testcase_28 AC 385 ms
80,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

n, m, k = map(int, input().split())

lr = [list(map(int, input().split())) for _ in range(m)]
dp = [0] * (n + 1)
dp[0] = 1
for _ in range(k):
    cum = [0]
    for d in dp[:-1]:
        cum.append(cum[-1] + d)
        if cum[-1] >= MOD:
            cum[-1] -= MOD
    ndp = [0] * (n + 1)
    for l, r in lr:
        plus = (cum[r] - cum[l - 1]) % MOD
        ndp[l - 1] += plus
        ndp[r] -= plus
    for i in range(1, n + 1):
        ndp[i] += ndp[i - 1]
        ndp[i] %= MOD
    dp = ndp
print(dp[n - 1])
0