結果

問題 No.801 エレベーター
ユーザー simansiman
提出日時 2022-05-27 15:21:50
言語 C++17(clang)
(14.0.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 1,093 bytes
コンパイル時間 1,031 ms
コンパイル使用メモリ 131,136 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 19:42:00
合計ジャッジ時間 4,394 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 4 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 139 ms
4,348 KB
testcase_14 AC 143 ms
4,348 KB
testcase_15 AC 143 ms
4,348 KB
testcase_16 AC 136 ms
4,348 KB
testcase_17 AC 142 ms
4,348 KB
testcase_18 AC 140 ms
4,348 KB
testcase_19 AC 141 ms
4,348 KB
testcase_20 AC 143 ms
4,348 KB
testcase_21 AC 148 ms
4,348 KB
testcase_22 AC 144 ms
4,348 KB
testcase_23 AC 140 ms
4,348 KB
testcase_24 AC 134 ms
4,348 KB
testcase_25 AC 132 ms
4,348 KB
testcase_26 AC 134 ms
4,348 KB
testcase_27 AC 135 ms
4,348 KB
testcase_28 AC 139 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAX_N = 3010;

ll dp[MAX_N];
ll RUI[MAX_N];
ll D[MAX_N];
int L[MAX_N];
int R[MAX_N];

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  for (int i = 0; i < M; ++i) {
    cin >> L[i] >> R[i];
  }

  memset(dp, 0, sizeof(dp));
  dp[1] = 1;

  for (int i = 0; i < K; ++i) {
    memset(RUI, 0, sizeof(RUI));

    for (int j = 1; j <= N; ++j) {
      RUI[j] = dp[j] + RUI[j - 1];
      RUI[j] %= MOD;
    }

    memset(D, 0, sizeof(D));

    for (int j = 0; j < M; ++j) {
      int l = L[j];
      int r = R[j];
      ll sum = (RUI[r] - RUI[l - 1]) % MOD;

      D[l] += sum;
      D[l] %= MOD;
      D[r + 1] -= sum;
      D[r + 1] %= MOD;
    }

    ll sum = 0;
    for (int j = 1; j <= N; ++j) {
      sum += (D[j] + MOD);
      sum %= MOD;
      dp[j] = sum;
    }
  }

  cout << dp[N] << endl;

  return 0;
}
0