結果

問題 No.801 エレベーター
ユーザー oxyshoweroxyshower
提出日時 2019-04-06 16:04:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 910 bytes
コンパイル時間 1,243 ms
コンパイル使用メモリ 147,000 KB
実行使用メモリ 74,096 KB
最終ジャッジ日時 2023-09-06 05:49:03
合計ジャッジ時間 6,048 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 5 ms
10,040 KB
testcase_04 AC 5 ms
10,068 KB
testcase_05 AC 5 ms
10,092 KB
testcase_06 AC 5 ms
10,036 KB
testcase_07 AC 5 ms
10,044 KB
testcase_08 AC 6 ms
10,104 KB
testcase_09 AC 5 ms
10,012 KB
testcase_10 AC 5 ms
10,024 KB
testcase_11 AC 5 ms
10,032 KB
testcase_12 AC 5 ms
10,036 KB
testcase_13 AC 202 ms
73,904 KB
testcase_14 AC 201 ms
73,964 KB
testcase_15 AC 200 ms
73,748 KB
testcase_16 AC 203 ms
73,828 KB
testcase_17 AC 198 ms
73,812 KB
testcase_18 AC 205 ms
73,876 KB
testcase_19 AC 209 ms
73,912 KB
testcase_20 AC 207 ms
74,096 KB
testcase_21 AC 196 ms
73,916 KB
testcase_22 AC 199 ms
74,036 KB
testcase_23 AC 189 ms
73,824 KB
testcase_24 AC 195 ms
73,840 KB
testcase_25 AC 195 ms
73,844 KB
testcase_26 AC 198 ms
73,852 KB
testcase_27 AC 190 ms
73,772 KB
testcase_28 AC 208 ms
73,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long

const int MOD = 1e9+7;

int dp[3010][3010];
//i回目の移動でj階にいる場合の数

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

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

  dp[0][1] = 1;
  for(int i = 0; i < K; i++){
    vector<int> dp2(N+1,0); //累積和
    for(int j = 1; j <= N; j++){
      dp2[j] += dp2[j-1] + dp[i][j];
      dp2[j] %= MOD;
    }
    for(int j = 0; j < M; j++){
      int sum = dp2[R[j]] - dp2[L[j]-1] + MOD;
      sum %= MOD;
      dp[i+1][L[j]] += sum;
      dp[i+1][L[j]] %= MOD;
      dp[i+1][R[j]+1] -= sum,dp[i+1][R[j]+1] += MOD;
      dp[i+1][R[j]+1] %= MOD;
    }

    for(int j = 1; j <= N; j++){
      dp[i+1][j] += dp[i+1][j-1];
      dp[i+1][j] %= MOD;
    }
  }
  cout << dp[K][N] << endl;

  return 0;
}
0