結果

問題 No.844 split game
ユーザー betrue12betrue12
提出日時 2019-06-28 21:39:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 1,691 ms
コンパイル使用メモリ 171,216 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2023-09-14 21:43:58
合計ジャッジ時間 5,986 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
6,568 KB
testcase_01 AC 33 ms
7,068 KB
testcase_02 AC 85 ms
7,408 KB
testcase_03 AC 62 ms
7,360 KB
testcase_04 AC 32 ms
6,532 KB
testcase_05 AC 97 ms
7,764 KB
testcase_06 AC 31 ms
6,376 KB
testcase_07 AC 24 ms
6,376 KB
testcase_08 AC 17 ms
5,972 KB
testcase_09 AC 73 ms
6,972 KB
testcase_10 AC 105 ms
7,548 KB
testcase_11 AC 100 ms
8,128 KB
testcase_12 AC 71 ms
6,952 KB
testcase_13 AC 44 ms
6,504 KB
testcase_14 AC 44 ms
6,804 KB
testcase_15 AC 111 ms
8,024 KB
testcase_16 AC 111 ms
8,320 KB
testcase_17 AC 109 ms
8,040 KB
testcase_18 AC 108 ms
8,300 KB
testcase_19 AC 108 ms
8,028 KB
testcase_20 AC 109 ms
8,108 KB
testcase_21 AC 109 ms
8,028 KB
testcase_22 AC 108 ms
8,040 KB
testcase_23 AC 6 ms
5,924 KB
testcase_24 AC 10 ms
5,960 KB
testcase_25 AC 7 ms
5,800 KB
testcase_26 AC 5 ms
5,840 KB
testcase_27 AC 8 ms
6,012 KB
testcase_28 AC 4 ms
5,852 KB
testcase_29 AC 8 ms
5,856 KB
testcase_30 AC 9 ms
5,964 KB
testcase_31 AC 8 ms
5,812 KB
testcase_32 AC 5 ms
5,824 KB
testcase_33 AC 11 ms
5,908 KB
testcase_34 AC 8 ms
5,924 KB
testcase_35 AC 13 ms
6,004 KB
testcase_36 AC 9 ms
5,860 KB
testcase_37 AC 17 ms
6,332 KB
testcase_38 AC 32 ms
6,728 KB
testcase_39 AC 65 ms
7,020 KB
testcase_40 AC 22 ms
6,356 KB
testcase_41 AC 3 ms
5,656 KB
testcase_42 AC 4 ms
5,788 KB
testcase_43 AC 4 ms
5,632 KB
testcase_44 AC 3 ms
5,816 KB
testcase_45 AC 3 ms
5,716 KB
testcase_46 AC 4 ms
5,912 KB
testcase_47 AC 3 ms
5,720 KB
testcase_48 AC 3 ms
5,744 KB
testcase_49 AC 3 ms
5,652 KB
testcase_50 AC 3 ms
5,632 KB
testcase_51 AC 3 ms
5,780 KB
testcase_52 AC 3 ms
5,712 KB
testcase_53 AC 4 ms
5,656 KB
testcase_54 AC 3 ms
5,776 KB
testcase_55 AC 4 ms
5,720 KB
testcase_56 AC 3 ms
5,780 KB
testcase_57 AC 4 ms
5,752 KB
testcase_58 AC 3 ms
5,644 KB
testcase_59 AC 3 ms
5,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

void chmax(int64_t& a, int64_t b){
    a = max(a, b);
}

int main(){
    int N, M, A;
    cin >> N >> M >> A;
    vector<pair<int, int>> R2LP[100001];
    for(int i=0; i<M; i++){
        int l, r, p;
        cin >> l >> r >> p;
        R2LP[r].push_back({l, p});
    }

    const int64_t INF = 1e18;
    vector<int64_t> dp(N+1, -INF);
    dp[0] = 0;
    int64_t mx = 0;
    for(int i=1; i<=N; i++){
        for(auto& p : R2LP[i]){
            int l = p.first, pt = p.second;
            int64_t cost = (i == N ? 0 : A);
            chmax(dp[i], dp[l-1] - cost + pt);
        }
        chmax(dp[i], mx - A);
        chmax(mx, dp[i]);
    }

    int64_t ans = *max_element(dp.begin(), dp.end());
    cout << ans << endl;
    return 0;
}
0