結果

問題 No.801 エレベーター
ユーザー pasoconhoshii
提出日時 2019-03-19 07:01:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 376 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,476 KB
実行使用メモリ 80,940 KB
最終ジャッジ日時 2024-09-13 03:40:02
合計ジャッジ時間 7,920 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

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

mod = 10**9+7
dp = [0] * (N+1)
dp[1] = 1

for i in range(1, K+1):
    imos = [0] * (N+2)
    ruiseki = [0]

    for d in dp[1:]:
        ruiseki.append( ruiseki[-1] + d )
    # print("ruiseki: ", ruiseki)

    for j in range(M): # $B%(%l%Y!<%?A4It(B
        l,r = LR[j]
        _sum = ruiseki[r] - ruiseki[l-1]
        imos[l] += _sum
        imos[r+1] -= _sum

    # print("imos: ", imos)
    ndp = [0] * (N+1) 

    for i in range(1,N+1):
         ndp[i] = (ndp[i-1] + imos[i]) % mod
         # print("i: ",i ,"ndp: ", ndp)

    dp  = ndp
print(dp[N] % mod)

0