結果

問題 No.801 エレベーター
コンテスト
ユーザー siman
提出日時 2022-05-27 14:46:48
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.89.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,033 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,561 ms
コンパイル使用メモリ 147,840 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-04-09 01:37:46
合計ジャッジ時間 8,482 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:29:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   29 |   ll dp[N + 1];
      |         ^~~~~
main.cpp:29:9: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:19:7: note: declared here
   19 |   int N, M, K;
      |       ^
main.cpp:34:12: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   34 |     ll RUI[N + 1];
      |            ^~~~~
main.cpp:34:12: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:19:7: note: declared here
   19 |   int N, M, K;
      |       ^
main.cpp:42:10: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   42 |     ll D[N + 1];
      |          ^~~~~
main.cpp:42:10: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:19:7: note: declared here
   19 |   int N, M, K;
      |       ^
3 warnings generated.

ソースコード

diff #
raw source code

#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