結果

問題 No.801 エレベーター
ユーザー AEnAEn
提出日時 2022-12-30 13:09:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 400 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 78,820 KB
最終ジャッジ日時 2023-08-16 19:51:57
合計ジャッジ時間 9,457 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,648 KB
testcase_01 AC 71 ms
71,480 KB
testcase_02 AC 71 ms
71,460 KB
testcase_03 AC 92 ms
76,884 KB
testcase_04 AC 93 ms
76,856 KB
testcase_05 AC 93 ms
76,856 KB
testcase_06 AC 93 ms
76,796 KB
testcase_07 AC 92 ms
76,660 KB
testcase_08 AC 91 ms
76,828 KB
testcase_09 AC 92 ms
76,756 KB
testcase_10 AC 94 ms
76,768 KB
testcase_11 AC 93 ms
76,896 KB
testcase_12 AC 89 ms
76,572 KB
testcase_13 AC 393 ms
78,352 KB
testcase_14 AC 395 ms
78,636 KB
testcase_15 AC 399 ms
78,760 KB
testcase_16 AC 396 ms
78,820 KB
testcase_17 AC 396 ms
78,336 KB
testcase_18 AC 396 ms
78,540 KB
testcase_19 AC 395 ms
78,436 KB
testcase_20 AC 394 ms
78,416 KB
testcase_21 AC 400 ms
78,436 KB
testcase_22 AC 399 ms
78,568 KB
testcase_23 AC 390 ms
78,396 KB
testcase_24 AC 388 ms
78,456 KB
testcase_25 AC 391 ms
78,532 KB
testcase_26 AC 394 ms
78,568 KB
testcase_27 AC 389 ms
78,336 KB
testcase_28 AC 312 ms
78,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
ele = [list(map(int, input().split())) for _ in range(M)]

dp = [0]*(N+1)
dp[0] = 1
dp[1] = -1
mod = 10**9+7
for i in range(K):
    for j in range(N):
        dp[j+1] += dp[j]
        dp[j+1] %= mod
    for j in range(N-1):
        dp[j+1] += dp[j]
        dp[j+1] %= mod
    ndp = [0]*(N+1)
    for l, r in ele:
        num = dp[r-1] if l==1 else dp[r-1]-dp[l-2]
        num %= mod
        ndp[l-1] += num
        ndp[l-1] %= mod
        ndp[r] -= num
        ndp[r] %= mod
    dp = ndp
for i in range(N):
    dp[i+1] += dp[i]
    dp[i+1] %= mod
print(dp[-2])
        
0