結果

問題 No.801 エレベーター
ユーザー peroonperoon
提出日時 2019-03-18 01:35:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,498 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 97,472 KB
実行使用メモリ 78,532 KB
最終ジャッジ日時 2023-09-22 16:28:27
合計ジャッジ時間 21,191 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
74,196 KB
testcase_01 AC 20 ms
74,124 KB
testcase_02 AC 21 ms
74,152 KB
testcase_03 AC 23 ms
74,208 KB
testcase_04 AC 23 ms
74,168 KB
testcase_05 AC 24 ms
74,432 KB
testcase_06 AC 24 ms
74,192 KB
testcase_07 AC 24 ms
74,164 KB
testcase_08 AC 24 ms
74,144 KB
testcase_09 AC 24 ms
74,156 KB
testcase_10 AC 23 ms
74,164 KB
testcase_11 AC 23 ms
74,304 KB
testcase_12 AC 23 ms
74,280 KB
testcase_13 AC 1,595 ms
74,244 KB
testcase_14 AC 1,625 ms
74,264 KB
testcase_15 AC 1,580 ms
74,224 KB
testcase_16 AC 1,573 ms
74,212 KB
testcase_17 AC 1,587 ms
74,220 KB
testcase_18 AC 1,595 ms
74,208 KB
testcase_19 AC 1,591 ms
74,188 KB
testcase_20 AC 1,616 ms
74,408 KB
testcase_21 AC 1,588 ms
74,352 KB
testcase_22 AC 1,607 ms
74,348 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0