結果
| 問題 | 
                            No.801 エレベーター
                             | 
                    
| コンテスト | |
| ユーザー | 
                             monnu
                         | 
                    
| 提出日時 | 2020-10-03 20:24:15 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 104 ms / 2,000 ms | 
| コード長 | 780 bytes | 
| コンパイル時間 | 1,655 ms | 
| コンパイル使用メモリ | 172,948 KB | 
| 実行使用メモリ | 73,728 KB | 
| 最終ジャッジ日時 | 2024-07-18 05:44:26 | 
| 合計ジャッジ時間 | 3,889 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
using ll=long long;
using Graph=vector<vector<int>>;
int main(){
  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];
    L[i]--;
  }
  vector<vector<ll>> dp(K+1,vector<ll>(N,0));
  dp[0][0]=1;
  for(int i=0;i<K;i++){
    vector<ll> sum(N+1,0);
    for(int j=0;j<N;j++){
      sum[j+1]=sum[j]+dp[i][j];
    }
    vector<ll> diff(N+1,0);
    for(int j=0;j<M;j++){
      ll x=sum[R[j]]-sum[L[j]];
      x%=MOD;
      diff[L[j]]+=x;
      diff[R[j]]-=x;
    }
    dp[i+1][0]=diff[0];
    for(int j=1;j<N;j++){
      dp[i+1][j]=dp[i+1][j-1]+diff[j];
    }
    for(int j=0;j<N;j++){
      dp[i+1][j]%=MOD;
    }
  }
  cout<<dp[K][N-1]<<endl;
}
            
            
            
        
            
monnu