結果

問題 No.801 エレベーター
ユーザー kyort0nkyort0n
提出日時 2019-03-17 21:41:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 1,035 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 165,300 KB
実行使用メモリ 144,516 KB
最終ジャッジ日時 2023-09-22 04:36:20
合計ジャッジ時間 6,329 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,412 KB
testcase_01 AC 2 ms
5,544 KB
testcase_02 AC 2 ms
5,528 KB
testcase_03 AC 7 ms
13,364 KB
testcase_04 AC 7 ms
13,396 KB
testcase_05 AC 7 ms
13,348 KB
testcase_06 AC 7 ms
13,600 KB
testcase_07 AC 8 ms
13,440 KB
testcase_08 AC 7 ms
14,992 KB
testcase_09 AC 7 ms
13,376 KB
testcase_10 AC 8 ms
13,600 KB
testcase_11 AC 7 ms
13,384 KB
testcase_12 AC 7 ms
13,396 KB
testcase_13 AC 224 ms
144,284 KB
testcase_14 AC 246 ms
144,428 KB
testcase_15 AC 221 ms
144,116 KB
testcase_16 AC 217 ms
144,308 KB
testcase_17 AC 220 ms
144,236 KB
testcase_18 AC 220 ms
144,252 KB
testcase_19 AC 220 ms
144,256 KB
testcase_20 AC 218 ms
144,208 KB
testcase_21 AC 220 ms
144,276 KB
testcase_22 AC 223 ms
144,376 KB
testcase_23 AC 208 ms
144,288 KB
testcase_24 AC 207 ms
144,180 KB
testcase_25 AC 207 ms
144,208 KB
testcase_26 AC 207 ms
144,352 KB
testcase_27 AC 206 ms
144,184 KB
testcase_28 AC 207 ms
144,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll dp[3005][3005];
ll dpsum[3005][3005];
ll N, M, K;
ll L[3005], R[3005];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> K;
    for(int i = 1; i <= M; i++) cin >> L[i] >> R[i];
    dp[0][1] = 1;
    for(int i = 1; i <= N; i++) dpsum[0][i] = 1;
    for(int day = 1; day <= K; day++) {
        for(int m = 1; m <= M; m++) {
            ll before = (dpsum[day-1][R[m]] - dpsum[day-1][L[m]-1] % mod) % mod;
            dp[day][L[m]] += before;
            dp[day][R[m]+1] += mod - before;
            dp[day][L[m]] %= mod;
            dp[day][R[m]+1] %= mod;
        }
        for(int i = 1; i <= N; i++) dp[day][i] = (dp[day][i] + dp[day][i-1]) % mod;
        for(int i = 1; i <= N; i++) dpsum[day][i] = (dpsum[day][i-1] + dp[day][i]) % mod;
    }
    cout << dp[K][N] << endl;
    return 0;
}
0