結果

問題 No.801 エレベーター
ユーザー koi_kotyakoi_kotya
提出日時 2019-03-18 21:43:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 1,205 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 170,116 KB
実行使用メモリ 38,664 KB
最終ジャッジ日時 2023-09-26 10:17:45
合計ジャッジ時間 6,454 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 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 4 ms
4,500 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 4 ms
4,384 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 194 ms
38,236 KB
testcase_14 AC 192 ms
38,416 KB
testcase_15 AC 192 ms
38,120 KB
testcase_16 AC 192 ms
38,156 KB
testcase_17 AC 192 ms
38,076 KB
testcase_18 AC 192 ms
38,212 KB
testcase_19 AC 192 ms
38,104 KB
testcase_20 AC 192 ms
38,080 KB
testcase_21 AC 192 ms
38,464 KB
testcase_22 AC 193 ms
38,200 KB
testcase_23 AC 185 ms
38,108 KB
testcase_24 AC 186 ms
38,136 KB
testcase_25 AC 186 ms
38,236 KB
testcase_26 AC 186 ms
38,384 KB
testcase_27 AC 186 ms
38,384 KB
testcase_28 AC 189 ms
38,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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];
    vector<vector<int>> dp(k+1,vector<int>(n+2,0));
    dp[0][1] = 1;
    for (int i = 0;i < k;++i) {
        for (int j = 0;j < n+1;++j) {
            dp[i][j+1] += dp[i][j];
            dp[i][j+1] %= mod;
        }
        for (int j = 0;j < m;++j) {
            int s = (dp[i][r[j]]-dp[i][l[j]-1])%mod;
            dp[i+1][l[j]] += s;
            dp[i+1][l[j]] %= mod;
            dp[i+1][r[j]+1] -= s;
            dp[i+1][r[j]+1] %= mod;
        }
        for (int j = 0;j < n+1;++j) {
            dp[i+1][j+1] += dp[i+1][j];
            dp[i+1][j+1] %= mod;
        }
    }
    cout << (dp[k][n]+mod)%mod << endl;
    return 0;
}
0