結果

問題 No.801 エレベーター
ユーザー sinsincoscossinsincoscos
提出日時 2019-03-17 22:35:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 659 ms / 2,000 ms
コード長 1,001 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 53,100 KB
実行使用メモリ 74,264 KB
最終ジャッジ日時 2023-09-22 08:24:28
合計ジャッジ時間 12,560 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 9 ms
10,116 KB
testcase_04 AC 9 ms
10,056 KB
testcase_05 AC 9 ms
10,020 KB
testcase_06 AC 9 ms
10,004 KB
testcase_07 AC 9 ms
10,100 KB
testcase_08 AC 9 ms
10,044 KB
testcase_09 AC 9 ms
10,020 KB
testcase_10 AC 9 ms
10,160 KB
testcase_11 AC 9 ms
10,000 KB
testcase_12 AC 9 ms
10,080 KB
testcase_13 AC 653 ms
73,908 KB
testcase_14 AC 653 ms
74,008 KB
testcase_15 AC 659 ms
73,780 KB
testcase_16 AC 648 ms
73,952 KB
testcase_17 AC 648 ms
73,896 KB
testcase_18 AC 648 ms
73,852 KB
testcase_19 AC 654 ms
73,880 KB
testcase_20 AC 650 ms
73,876 KB
testcase_21 AC 649 ms
74,036 KB
testcase_22 AC 650 ms
73,984 KB
testcase_23 AC 640 ms
73,828 KB
testcase_24 AC 638 ms
73,884 KB
testcase_25 AC 639 ms
73,900 KB
testcase_26 AC 640 ms
73,824 KB
testcase_27 AC 639 ms
73,864 KB
testcase_28 AC 641 ms
74,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

int N,M,K;
int L[3010],R[3010];
ll dp[3010][3010] = {},imos[3010] = {},elv[3010] = {},inf = 1e9+7;
int main(){
    cin >> N >> M >> K;
    for(int i=1;i<=M;i++){
        cin >> L[i] >> R[i];
    }
    dp[0][1] = 1;
    for(int k=1;k<=K;k++){
        for(int i=1;i<=N;i++){
            (dp[k-1][i] += dp[k-1][i-1])%=inf;//累積和
        }
        //エレベーター内の移動の総数
        for(int i=1;i<=N;i++){
            imos[i] = 0;
        }
        for(int i=1;i<=M;i++){
            elv[i] = (dp[k-1][R[i]]-dp[k-1][L[i]-1]+inf)%inf;
            (imos[L[i]] += elv[i])%=inf;
            (imos[R[i]+1] += -elv[i]+inf)%=inf;
        }
        for(int i=1;i<=N;i++){
            (imos[i] += imos[i-1])%=inf;
            dp[k][i] = imos[i];
        }
    }
/*    for(int i=1;i<=K;i++){
        for(int j=1;j<=N;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
*/    cout << dp[K][N] << endl;
}
0