結果

問題 No.844 split game
ユーザー t98slidert98slider
提出日時 2023-08-01 03:27:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 171,252 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-04-19 03:11:31
合計ジャッジ時間 5,521 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
5,632 KB
testcase_01 AC 16 ms
8,448 KB
testcase_02 AC 37 ms
6,656 KB
testcase_03 AC 28 ms
8,192 KB
testcase_04 AC 15 ms
5,632 KB
testcase_05 AC 41 ms
8,576 KB
testcase_06 AC 15 ms
5,504 KB
testcase_07 AC 14 ms
7,424 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 AC 29 ms
5,376 KB
testcase_10 AC 52 ms
8,064 KB
testcase_11 AC 39 ms
9,600 KB
testcase_12 AC 26 ms
5,376 KB
testcase_13 AC 18 ms
5,376 KB
testcase_14 AC 20 ms
7,168 KB
testcase_15 AC 47 ms
9,856 KB
testcase_16 AC 48 ms
9,728 KB
testcase_17 AC 48 ms
9,856 KB
testcase_18 AC 50 ms
9,984 KB
testcase_19 AC 47 ms
9,728 KB
testcase_20 AC 43 ms
9,728 KB
testcase_21 AC 44 ms
9,856 KB
testcase_22 AC 45 ms
9,856 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 5 ms
5,376 KB
testcase_30 AC 5 ms
5,376 KB
testcase_31 AC 4 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 AC 4 ms
5,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 12 ms
5,376 KB
testcase_39 AC 25 ms
5,376 KB
testcase_40 AC 10 ms
6,400 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 WA -
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 1 ms
5,376 KB
testcase_55 WA -
testcase_56 AC 2 ms
5,376 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, A, l, r, c;
    cin >> n >> m >> A;
    vector<vector<pair<int, int>>> g(n);
    for(int i = 0; i < m; i++){
        cin >> l >> r >> c;
        l--, r--;
        g[l].emplace_back(r, c);
    }
    const ll INF = 1ll << 60;
    vector<array<ll, 3>> dp(n, array<ll, 3>({-INF, -INF, -INF}));
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for(int i = 0; i + 1 < n; i++){
        for(auto &&pa : g[i]){
            tie(r, c) = pa;
            dp[r][2] = max(dp[r][2], dp[i][1] + c);
        }
        dp[i + 1][0] = max(dp[i + 1][0], dp[i][0]);
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] - A);
        dp[i + 1][0] = max(dp[i + 1][0], dp[i][2] - A);
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][2] - A);
    }
    cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << '\n';
}
0