結果

問題 No.801 エレベーター
ユーザー qibqib
提出日時 2023-01-04 14:19:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 365 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 78,648 KB
最終ジャッジ日時 2023-08-18 12:12:05
合計ジャッジ時間 9,112 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,176 KB
testcase_01 AC 66 ms
71,248 KB
testcase_02 AC 67 ms
71,252 KB
testcase_03 AC 90 ms
76,564 KB
testcase_04 AC 83 ms
76,556 KB
testcase_05 AC 86 ms
76,580 KB
testcase_06 AC 83 ms
76,468 KB
testcase_07 AC 90 ms
76,552 KB
testcase_08 AC 87 ms
76,556 KB
testcase_09 AC 88 ms
76,444 KB
testcase_10 AC 87 ms
76,364 KB
testcase_11 AC 84 ms
76,540 KB
testcase_12 AC 88 ms
76,500 KB
testcase_13 AC 356 ms
78,312 KB
testcase_14 AC 354 ms
78,164 KB
testcase_15 AC 355 ms
78,180 KB
testcase_16 AC 362 ms
78,248 KB
testcase_17 AC 357 ms
78,528 KB
testcase_18 AC 353 ms
78,228 KB
testcase_19 AC 361 ms
78,368 KB
testcase_20 AC 365 ms
78,208 KB
testcase_21 AC 349 ms
78,080 KB
testcase_22 AC 355 ms
78,184 KB
testcase_23 AC 347 ms
78,160 KB
testcase_24 AC 350 ms
78,164 KB
testcase_25 AC 351 ms
78,144 KB
testcase_26 AC 346 ms
78,380 KB
testcase_27 AC 356 ms
78,648 KB
testcase_28 AC 335 ms
78,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

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

elevators = [list(map(int, input().split())) for _ in range(m)]

dp = [0 for _ in range(n + 2)]
dp[1] = 1
for _ in range(k):
  s = [0 for _ in range(n + 2)]
  for i in range(1, n + 2):
    s[i] = (s[i - 1] + dp[i]) % MOD

  ndp = [0 for _ in range(n + 2)]
  for l, r in elevators:
    ndp[l] = (ndp[l] + s[r] - s[l - 1]) % MOD
    ndp[r + 1] = (ndp[r + 1] - s[r] + s[l - 1]) % MOD

  for i in range(1, n + 2):
    ndp[i] = (ndp[i - 1] + ndp[i]) % MOD

  dp = ndp

print(dp[n])
0