結果

問題 No.801 エレベーター
ユーザー 37zigen37zigen
提出日時 2019-03-17 23:24:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 1,191 ms
コンパイル使用メモリ 145,596 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 11:06:56
合計ジャッジ時間 4,893 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

int L[3000];
int R[3000];

long long mo=1e9+7;
long long dp[2][3001];
long long sum[3000];

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

  for(int i=0;i<2;++i){
    for(int j=0;j<=3000;++j){
      dp[i][j]=0;
    }
  }
  
  for(int i=0;i<M;++i){
    std::cin>>L[i]>>R[i];
    --L[i];
    --R[i];
  }
  
  dp[0][0]=1;
  
  for(int i=0;i<K;++i){
    for(int j=0;j<N;++j){
      sum[j]=dp[i%2][j];
    }
    
    for(int j=1;j<N;++j){
      sum[j]+=sum[j-1];
    }
    
    for(int j=0;j<M;++j){
      long long add=sum[R[j]]-(L[j]-1<0?0:sum[L[j]-1]);
      dp[(i+1)%2][L[j]]+=add;
      dp[(i+1)%2][R[j]+1]-=add;
    }
    
    for(int j=0;j<=N;++j){
      dp[i%2][j]=0;
    }
    
    for(int j=1;j<N;++j){
      dp[(i+1)%2][j]+=dp[(i+1)%2][j-1];
    }
    for(int j=0;j<N;++j)dp[(i+1)%2][j]%=mo;
  }
  
  std::cout<<dp[K%2][N-1]<<std::endl;
  
  return 0;
}


0