結果

問題 No.801 エレベーター
ユーザー terasaterasa
提出日時 2022-06-03 10:59:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 557 ms / 2,000 ms
コード長 1,462 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 212,908 KB
最終ジャッジ日時 2023-10-21 01:26:34
合計ジャッジ時間 10,830 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,748 KB
testcase_01 AC 44 ms
55,748 KB
testcase_02 AC 43 ms
55,748 KB
testcase_03 AC 64 ms
70,872 KB
testcase_04 AC 65 ms
70,880 KB
testcase_05 AC 66 ms
70,880 KB
testcase_06 AC 71 ms
72,928 KB
testcase_07 AC 67 ms
72,928 KB
testcase_08 AC 68 ms
72,928 KB
testcase_09 AC 67 ms
70,880 KB
testcase_10 AC 64 ms
70,880 KB
testcase_11 AC 67 ms
70,880 KB
testcase_12 AC 69 ms
70,880 KB
testcase_13 AC 552 ms
212,832 KB
testcase_14 AC 544 ms
212,888 KB
testcase_15 AC 544 ms
212,844 KB
testcase_16 AC 552 ms
212,848 KB
testcase_17 AC 546 ms
212,844 KB
testcase_18 AC 557 ms
212,908 KB
testcase_19 AC 533 ms
212,800 KB
testcase_20 AC 554 ms
212,796 KB
testcase_21 AC 544 ms
212,808 KB
testcase_22 AC 545 ms
212,908 KB
testcase_23 AC 537 ms
212,868 KB
testcase_24 AC 531 ms
212,872 KB
testcase_25 AC 540 ms
212,872 KB
testcase_26 AC 521 ms
212,812 KB
testcase_27 AC 527 ms
212,812 KB
testcase_28 AC 455 ms
212,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


N, M, K = map(int, input().split())
E = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]
mod = 10 ** 9 + 7

dp = [[0 for _ in range(N)] for _ in range(K + 1)]
S = [[0 for _ in range(N)] for _ in range(K + 1)]
dp[0][0] = 1
for j in range(N):
    S[0][j] = 1

for i in range(K):
    for l, r in E:
        s = S[i][r] - (S[i][l - 1] if l > 0 else 0)
        dp[i + 1][l] += s
        if r + 1 < N:
            dp[i + 1][r + 1] -= s

    for j in range(1, N):
        dp[i + 1][j] += dp[i + 1][j - 1]
        dp[i + 1][j] %= mod

    S[i + 1][0] = dp[i + 1][0]
    for j in range(1, N):
        S[i + 1][j] = dp[i + 1][j] + S[i + 1][j - 1]
        S[i + 1][j] %= mod
print(dp[K][N - 1])
0