結果

問題 No.801 エレベーター
ユーザー At-sushiAt-sushi
提出日時 2019-07-14 14:52:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 952 bytes
コンパイル時間 2,915 ms
コンパイル使用メモリ 209,076 KB
実行使用メモリ 80,800 KB
最終ジャッジ日時 2024-05-03 06:06:13
合計ジャッジ時間 8,451 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
80,668 KB
testcase_01 AC 52 ms
73,856 KB
testcase_02 AC 52 ms
73,728 KB
testcase_03 AC 215 ms
73,728 KB
testcase_04 AC 223 ms
73,856 KB
testcase_05 AC 215 ms
73,856 KB
testcase_06 AC 219 ms
73,856 KB
testcase_07 AC 231 ms
73,728 KB
testcase_08 AC 228 ms
73,728 KB
testcase_09 AC 222 ms
73,728 KB
testcase_10 AC 224 ms
73,728 KB
testcase_11 AC 229 ms
73,728 KB
testcase_12 AC 226 ms
73,728 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    int N, M, K;
    
    cin>> N >> M >> K;
    
    vector<int> L(M), R(M);
    vector<vector<long long >> dp(3001, vector<long long>(3001, -1));
    
    for (int i = 0; i < M; i++)
        cin >> L[i] >> R[i];
        
    for (int i = 0; i < M; i++)
    	dp[K][i] = (N <= R[i]) ? 1 : 0;
    
    auto solve = [&](auto f, int k, int m) {
        if (dp[k][m] >= 0)
            return dp[k][m];
            
        long long r = 0LL;
        for (int i = 0; i < M; i++)
            if (min(R[m], R[i]) >= max(L[m], L[i]))
                r = (r + f(f, k + 1, i) * (min(R[m], R[i]) - max(L[m], L[i]) + 1) % 1000000007) % 1000000007;;
                    
        dp[k][m] = r;
        return r;
    };
    
    long long r = 0;
    
    for (int i = 0; i < M; i++)
        if (1 >= L[i])
        	r = (r + solve(solve, 1, i)) % 1000000007;
    
    cout << r << endl;
    
    return 0;
}
0