結果

問題 No.801 エレベーター
ユーザー At-sushiAt-sushi
提出日時 2019-07-14 15:24:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,193 bytes
コンパイル時間 2,396 ms
コンパイル使用メモリ 211,928 KB
実行使用メモリ 79,488 KB
最終ジャッジ日時 2024-05-03 06:44:02
合計ジャッジ時間 10,954 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
79,104 KB
testcase_01 AC 54 ms
73,856 KB
testcase_02 AC 53 ms
73,728 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
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<pair<int, int>> LR(M);
    vector<vector<long long >> dp(3001, vector<long long>(3001, -1));
    
    for (int i = 0; i < M; i++) {
    	int a, b;
    	
        cin >> a >> b;
        LR[i] = make_pair(a, b);
    }
    sort(LR.begin(), LR.end());
        
    for (int i = 0; i < M; i++)
    	dp[K][i] = (N <= LR[i].second) ? 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 < upper_bound(LR.begin(), LR.end(), make_pair(LR[m].second, 0)) - LR.begin(); i++)
            if (min(LR[m].second, LR[i].second) >= max(LR[m].first, LR[i].first))
                r = (r + f(f, k + 1, i) * (min(LR[m].second, LR[i].second) - max(LR[m].first, LR[i].first) + 1) % 1000000007) % 1000000007;
                    
        dp[k][m] = r;
        return r;
    };
    
    long long r = 0;
    
    for (int i = 0; i < M; i++)
        if (1 >= LR[i].first)
        	r = (r + solve(solve, 1, i)) % 1000000007;
    
    cout << r << endl;
    
    return 0;
}
0