結果

問題 No.801 エレベーター
ユーザー ikdikd
提出日時 2019-03-18 10:46:12
言語 Nim
(2.0.0)
結果
TLE  
実行時間 -
コード長 708 bytes
コンパイル時間 3,778 ms
コンパイル使用メモリ 68,792 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-14 15:28:05
合計ジャッジ時間 10,610 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 239 ms
4,376 KB
testcase_04 AC 248 ms
4,380 KB
testcase_05 AC 229 ms
4,380 KB
testcase_06 AC 239 ms
4,380 KB
testcase_07 AC 252 ms
4,376 KB
testcase_08 AC 247 ms
4,376 KB
testcase_09 AC 236 ms
4,376 KB
testcase_10 AC 241 ms
4,380 KB
testcase_11 AC 228 ms
4,380 KB
testcase_12 AC 244 ms
4,384 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

const mo = 1000000000 + 7
proc add(a: var int64, b: int64) =
  a += b
  if a >= mo:
    a -= mo
proc sub(a: var int64, b: int64) =
  a -= b
  if a < 0:
    a += mo

proc main() =
  let
    nmk = stdin.readLine.strip.split.map(parseInt)
    (n, m, k) = (nmk[0], nmk[1], nmk[2])
    lr = (0..<m).mapIt(stdin.readLine.strip.split.map(parseInt))

  var dp = newSeqWith(k + 1, newSeq[int64](n + 1))
  dp[0][0] = 1
  for i in 0..<k:
    for j in 0..<n:
      for s in lr:
        if s[0] - 1 <= j and j < s[1]:
          add(dp[i + 1][s[0] - 1], dp[i][j])
          sub(dp[i + 1][s[1]], dp[i][j])
    for j in 0..<n:
      add(dp[i + 1][j + 1], dp[i + 1][j])

  echo dp[k][n - 1]
main()
0