結果

問題 No.801 エレベーター
ユーザー tottoripapertottoripaper
提出日時 2019-03-18 19:53:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 1,084 bytes
コンパイル時間 1,597 ms
コンパイル使用メモリ 166,740 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 22:17:33
合計ジャッジ時間 5,533 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
int N, M, K;
int L[3100], R[3100];

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N >> M >> K;

    for(int i=0;i<M;++i){
        std::cin >> L[i] >> R[i];
    }

    std::vector<ll> dp(N + 1, 0);
    dp[1] = 1;

    for(int _=0;_<K;++_){
        for(int i=2;i<=N;++i){
            dp[i] = (dp[i] + dp[i-1]) % MOD;
        }

        std::vector<ll> v(N + 1, 0);

        for(int i=0;i<M;++i){
            ll s = (dp[R[i]] + MOD - dp[L[i]-1]) % MOD;
            v[L[i]] = (v[L[i]] + s) % MOD;
            if(R[i] < N){
                v[R[i]+1] = (v[R[i]+1] + MOD - s) % MOD;
            }
        }

        for(int i=2;i<=N;++i){
            v[i] = (v[i] + v[i-1]) % MOD;
        }

        dp = std::move(v);
    }

    ll c = dp[N];
    std::cout << c << std::endl;
}
0