結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 35 ms
8,992 KB
testcase_02 WA -
testcase_03 AC 64 ms
9,720 KB
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 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 113 ms
10,624 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 13 ms
8,584 KB
testcase_34 WA -
testcase_35 AC 15 ms
8,360 KB
testcase_36 AC 11 ms
8,384 KB
testcase_37 AC 20 ms
8,516 KB
testcase_38 AC 32 ms
8,968 KB
testcase_39 AC 64 ms
10,236 KB
testcase_40 AC 23 ms
8,604 KB
testcase_41 AC 5 ms
8,012 KB
testcase_42 AC 5 ms
8,028 KB
testcase_43 AC 5 ms
7,972 KB
testcase_44 AC 5 ms
8,012 KB
testcase_45 AC 5 ms
7,992 KB
testcase_46 AC 5 ms
8,100 KB
testcase_47 AC 4 ms
8,124 KB
testcase_48 WA -
testcase_49 AC 5 ms
8,012 KB
testcase_50 AC 5 ms
7,968 KB
testcase_51 AC 5 ms
8,020 KB
testcase_52 AC 5 ms
8,196 KB
testcase_53 WA -
testcase_54 AC 5 ms
8,056 KB
testcase_55 AC 5 ms
7,996 KB
testcase_56 AC 5 ms
7,972 KB
testcase_57 AC 5 ms
7,980 KB
testcase_58 AC 5 ms
8,264 KB
testcase_59 AC 5 ms
8,020 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] = {};
    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