結果

問題 No.801 エレベーター
ユーザー veqccveqcc
提出日時 2019-03-17 22:16:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 241 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 1,111 ms
コンパイル使用メモリ 102,944 KB
実行使用メモリ 73,884 KB
最終ジャッジ日時 2023-09-22 07:19:39
合計ジャッジ時間 5,827 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 5 ms
5,224 KB
testcase_04 AC 5 ms
5,212 KB
testcase_05 AC 5 ms
5,248 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 5 ms
5,304 KB
testcase_08 AC 5 ms
5,536 KB
testcase_09 AC 5 ms
5,224 KB
testcase_10 AC 5 ms
5,228 KB
testcase_11 AC 6 ms
5,520 KB
testcase_12 AC 5 ms
5,248 KB
testcase_13 AC 241 ms
73,780 KB
testcase_14 AC 241 ms
73,828 KB
testcase_15 AC 239 ms
73,636 KB
testcase_16 AC 240 ms
73,704 KB
testcase_17 AC 238 ms
73,704 KB
testcase_18 AC 241 ms
73,700 KB
testcase_19 AC 239 ms
73,828 KB
testcase_20 AC 239 ms
73,724 KB
testcase_21 AC 239 ms
73,824 KB
testcase_22 AC 239 ms
73,860 KB
testcase_23 AC 231 ms
73,692 KB
testcase_24 AC 232 ms
73,740 KB
testcase_25 AC 232 ms
73,764 KB
testcase_26 AC 233 ms
73,784 KB
testcase_27 AC 233 ms
73,676 KB
testcase_28 AC 231 ms
73,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const ll MOD = 1000000007LL;
ll dp[3005][3005];

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);

    int n, m, k;
    cin >> n >> m >> k;

    int l[m], r[m];
    for (int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
        l[i]--; r[i]--;
    }

    dp[0][0] = 1;
    for (int i = 0; i < k; i++) {

        // 累積和
        vector <ll> vec(n);
        for (int j = 0; j < n; j++) {
            vec[j] = dp[i][j];
            if (j) vec[j] += vec[j-1];
            vec[j] %= MOD;
        }

        // いもす法(?)
        for (int j = 0; j < m; j++) {
            ll cnt = vec[r[j]];
            if (l[j]) cnt -= vec[l[j] - 1];
            cnt = (cnt + MOD) % MOD;

            (dp[i+1][l[j]] += cnt) %= MOD;
            (dp[i+1][r[j] + 1] += MOD - cnt) %= MOD;
        }

        for (int j = 1; j < n; j++) {
            (dp[i+1][j] += dp[i+1][j-1]) %= MOD;
        }
    }

    cout << dp[k][n-1] << "\n";
    return 0;
}
0