結果

問題 No.801 エレベーター
ユーザー ShibuyapShibuyap
提出日時 2019-10-29 15:06:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 333 ms / 2,000 ms
コード長 1,300 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 165,212 KB
実行使用メモリ 73,992 KB
最終ジャッジ日時 2023-10-12 23:23:22
合計ジャッジ時間 8,408 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 6 ms
5,208 KB
testcase_04 AC 7 ms
5,428 KB
testcase_05 AC 7 ms
5,188 KB
testcase_06 AC 7 ms
5,232 KB
testcase_07 AC 7 ms
5,304 KB
testcase_08 AC 7 ms
5,408 KB
testcase_09 AC 7 ms
5,280 KB
testcase_10 AC 7 ms
5,444 KB
testcase_11 AC 7 ms
5,312 KB
testcase_12 AC 7 ms
5,304 KB
testcase_13 AC 333 ms
73,912 KB
testcase_14 AC 333 ms
73,892 KB
testcase_15 AC 332 ms
73,700 KB
testcase_16 AC 332 ms
73,680 KB
testcase_17 AC 330 ms
73,728 KB
testcase_18 AC 331 ms
73,780 KB
testcase_19 AC 332 ms
73,836 KB
testcase_20 AC 329 ms
73,760 KB
testcase_21 AC 330 ms
73,856 KB
testcase_22 AC 323 ms
73,904 KB
testcase_23 AC 320 ms
73,728 KB
testcase_24 AC 319 ms
73,680 KB
testcase_25 AC 319 ms
73,992 KB
testcase_26 AC 321 ms
73,760 KB
testcase_27 AC 318 ms
73,660 KB
testcase_28 AC 210 ms
73,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 3005;
ll bit[MAX_N];
int n; // 1-index
const ll MOD = 1e9+7;

void adds(int a, ll w){
    for(int x = a; x <= n; x += x & -x) bit[x] += w;
}
ll sums(int a){ 
    ll ret = 0;
    for(int x = a; x > 0; x -= x & -x) ret += bit[x];  
    return ret;
}

ll dp[MAX_N][MAX_N];

int main() {
    int m, k;
    cin >> n >> m >> k;
    int l[m], r[m];
    rep(i,m)cin >> l[i] >> r[i];

    dp[0][1] = 1;

    srep(i,1,k+1){
        rep(j,MAX_N)bit[j] = 0;
        ll sum[MAX_N] = {};
        srep(j,1,MAX_N){
            sum[j] = sum[j-1] + dp[i-1][j];
        }
        rep(j,m){
            ll wa = sum[r[j]] - sum[l[j] - 1];
            wa %= MOD;
            adds(l[j], wa);
            adds(r[j]+1, -wa);
        }
        srep(j,1,n+1){
            dp[i][j] = sums(j);
            dp[i][j] %= MOD;
        }
        /*
        srep(j,1,n+1){
            cout << sums(j) << ' ';
        }
        cout << endl;
        */
    }

    dp[k][n] %= MOD;
    cout << dp[k][n] << endl;
    return 0;
}
 
 
0