結果

問題 No.801 エレベーター
ユーザー eQeeQe
提出日時 2019-06-11 14:22:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 1,377 bytes
コンパイル時間 1,715 ms
コンパイル使用メモリ 158,832 KB
実行使用メモリ 74,496 KB
最終ジャッジ日時 2024-04-15 20:41:45
合計ジャッジ時間 5,928 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 6 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 209 ms
74,368 KB
testcase_14 AC 212 ms
74,240 KB
testcase_15 AC 209 ms
74,368 KB
testcase_16 AC 209 ms
74,240 KB
testcase_17 AC 211 ms
74,240 KB
testcase_18 AC 210 ms
74,368 KB
testcase_19 AC 209 ms
74,496 KB
testcase_20 AC 209 ms
74,368 KB
testcase_21 AC 208 ms
74,496 KB
testcase_22 AC 210 ms
74,368 KB
testcase_23 AC 204 ms
74,368 KB
testcase_24 AC 202 ms
74,240 KB
testcase_25 AC 201 ms
74,368 KB
testcase_26 AC 199 ms
74,496 KB
testcase_27 AC 201 ms
74,368 KB
testcase_28 AC 225 ms
74,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

ll l[3030], r[3030];
ll c[3030][3030];
ll dp[3030][3030];//dp[i][j]:i回の操作後にj階にいる場合の数

int main(void) {
  ll N, M, K;
  cin >> N >> M >> K;
  ll i, j;
  
  
  for(i=0; i<M; i++) {
    cin >> l[i] >> r[i];
  }
  
  dp[0][1]=1; //はじめ1階にいるので
  for(i=0; i<K; i++) {
    ll s[3030]={};
    for(j=1; j<=N; j++) {
      //s[j]:dp[i][j]-dp[i][0]の和
      //→i回の操作後に1階~j階にいる場合の数
      s[j]=(s[j-1]+dp[i][j])%MOD;
    }
    
    for(j=0; j<M; j++) {
      //t:i回の操作後にl[j]階~r[j]階にいる場合の数
      //この範囲にいれば次にl[j]階~r[j]階の任意の階に移動できる
      ll t=s[r[j]]-s[l[j]-1];
      moC(dp[i+1][l[j]], +, t);
      moC(dp[i+1][r[j]+1], -, t);
    }
    
    for(j=0; j<N; j++) {
      moC(dp[i+1][j+1], +, dp[i+1][j]);
    }
  }
  
  pt(dp[K][N]);
  
}
0