結果

問題 No.801 エレベーター
ユーザー simansiman
提出日時 2022-05-27 14:46:48
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,033 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 131,948 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 19:41:33
合計ジャッジ時間 5,426 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 3 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 3 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 105 ms
4,348 KB
testcase_17 AC 105 ms
4,348 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 103 ms
4,348 KB
testcase_24 AC 103 ms
4,348 KB
testcase_25 AC 104 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 109 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;

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

  vector<int> L(M);
  vector<int> R(M);

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

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

  for (int i = 0; i < K; ++i) {
    ll RUI[N + 1];
    memset(RUI, 0, sizeof(RUI));

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

    ll D[N + 1];
    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];

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

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

  cout << dp[N] << endl;

  return 0;
}
0