結果

問題 No.844 split game
ユーザー Y17Y17
提出日時 2019-06-28 22:52:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,222 bytes
コンパイル時間 1,606 ms
コンパイル使用メモリ 148,748 KB
実行使用メモリ 10,932 KB
最終ジャッジ日時 2023-09-14 22:29:24
合計ジャッジ時間 6,074 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
9,112 KB
testcase_01 AC 36 ms
8,920 KB
testcase_02 AC 93 ms
10,412 KB
testcase_03 AC 67 ms
9,760 KB
testcase_04 AC 35 ms
8,952 KB
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 WA -
testcase_14 WA -
testcase_15 AC 116 ms
10,668 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 115 ms
10,664 KB
testcase_19 AC 115 ms
10,592 KB
testcase_20 AC 116 ms
10,860 KB
testcase_21 AC 116 ms
10,640 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 7 ms
8,104 KB
testcase_27 WA -
testcase_28 AC 6 ms
8,004 KB
testcase_29 AC 11 ms
8,148 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 6 ms
8,068 KB
testcase_33 AC 12 ms
8,412 KB
testcase_34 AC 9 ms
8,272 KB
testcase_35 AC 14 ms
8,400 KB
testcase_36 AC 11 ms
8,324 KB
testcase_37 AC 20 ms
8,452 KB
testcase_38 AC 32 ms
9,020 KB
testcase_39 AC 64 ms
10,000 KB
testcase_40 AC 23 ms
8,636 KB
testcase_41 AC 5 ms
7,980 KB
testcase_42 AC 5 ms
8,156 KB
testcase_43 AC 5 ms
8,104 KB
testcase_44 AC 6 ms
8,036 KB
testcase_45 AC 5 ms
8,032 KB
testcase_46 AC 6 ms
8,028 KB
testcase_47 AC 5 ms
7,968 KB
testcase_48 WA -
testcase_49 AC 4 ms
8,152 KB
testcase_50 AC 5 ms
8,040 KB
testcase_51 AC 4 ms
7,964 KB
testcase_52 AC 6 ms
8,036 KB
testcase_53 AC 4 ms
8,028 KB
testcase_54 AC 5 ms
8,020 KB
testcase_55 AC 5 ms
8,096 KB
testcase_56 AC 5 ms
8,036 KB
testcase_57 AC 6 ms
8,024 KB
testcase_58 AC 4 ms
8,020 KB
testcase_59 AC 6 ms
7,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long

vector<pair<int, int> > vec[100010];


signed main(){
    int n, m, a;
    cin >> n >> m >> a;


    for(int i = 0;i < m;i++){
        int l, r, p;
        cin >> l >> r >> p;
        l--;
        vec[l].push_back(make_pair(r, p));
    }

    int dp1[100010] = {};
    int d1tmp[100010] = {};
    int dp2[100010] = {};

    for(int i = 0;i < 100010;i++){
        dp1[i] = dp2[i] = -(1ll << 60);
    }
    dp1[0] = 0;
    dp2[0] = 0;

    d1tmp[0] = 1;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < vec[i].size();j++){
            int l = i;
            int r = vec[i][j].first;
            int p = vec[i][j].second;

            if(d1tmp[l]){
                dp1[r] = max(dp1[r], dp1[l]+p-(r == n ? 0 : a));
            }else{
                dp1[r] = max(dp1[r], dp1[l]+p-(r == n ? a : a*2));
            }

            dp2[r] = max(dp2[r], dp2[l]+p-(r == n ? a : a*2));
            dp1[r] = max(dp2[r], dp1[r]);

            d1tmp[r] = 1;
        }
        dp2[i+1] = max(dp2[i], dp2[i+1]);
    }

    int ans = 0;

    for(int i = 0;i <= n;i++){
        ans = max(ans, max(dp1[i], dp2[i]));
    }

    cout << ans << endl;
    return 0;
}
0