結果
| 問題 | 
                            No.801 エレベーター
                             | 
                    
| コンテスト | |
| ユーザー | 
                             peroon
                         | 
                    
| 提出日時 | 2019-03-18 01:34:16 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,459 bytes | 
| コンパイル時間 | 1,076 ms | 
| コンパイル使用メモリ | 101,452 KB | 
| 実行使用メモリ | 81,008 KB | 
| 最終ジャッジ日時 | 2024-07-08 07:59:15 | 
| 合計ジャッジ時間 | 23,401 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 TLE * 1 -- * 5 | 
ソースコード
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
const ll mod = 1e9 + 7;
const ll inf = 1e18;
ofstream of;
template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}
// k回目のl階
ll dp[3010][3010] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // input
    ll N, M, K;
    cin >> N >> M >> K;
    // 一応
    FOR(i, 0, 3010){
        FOR(j, 0, 3010){
            dp[i][j] = 0;
        }
    }
    of.open("log.txt");
    vector<ll> L(M);
    vector<ll> R(M);
    FOR(i, 0, M){
        ll l, r;
        cin >> l >> r;
        L[i] = l;
        R[i] = r;
    }
    
    // k = 0
    dp[0][1] = 1;
    FOR(i, 2, N+1){
        dp[0][i] = 0;
    }
    FOR(k, 1, K+1){
        of << endl;
        of << "k " << k << endl;
        // 累積和
        ll Ac[3010];
        Ac[0] = 0;
        FOR(i, 1, N+1){
            Ac[i] = dp[k-1][i];
        }
        // 累積
        FOR(i, 1, N+1){
            Ac[i] += Ac[i-1];
        }
        // FOR(i, 1, N+1){
            // cout << Ac[i] << " ";
        // }
        // 各エレベーターについて
        FOR(i, 0, M){
            ll l = L[i];
            ll r = R[i];
            ll sum = Ac[r] - Ac[l-1];
            // pn(sum);
            dp[k][l] += sum;
            // dp[k][l] %= mod;
            dp[k][r+1] -= sum;
        }
        of << "dp0" << endl;
        FOR(i, 1, N+2){
            of << dp[k][i] << " ";
        }
        of << endl;
        // simulation
        dp[k][0] = 0;
        FOR(i, 1, N+2){
            dp[k][i] += dp[k][i-1];
            while(dp[k][i]<0){
                dp[k][i] += mod;
            }
            dp[k][i] %= mod;
        }
        of << "dp" << endl;
        FOR(i, 1, N+2){
            of << dp[k][i] << " ";
        }
        of << endl;
    }
    ll answer = dp[K][N];
    p(answer % mod);
       
    return 0;
}
            
            
            
        
            
peroon