結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 35 ms
9,044 KB
testcase_02 WA -
testcase_03 AC 65 ms
9,996 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 115 ms
10,928 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,364 KB
testcase_34 WA -
testcase_35 AC 15 ms
8,380 KB
testcase_36 AC 11 ms
8,268 KB
testcase_37 AC 20 ms
8,460 KB
testcase_38 AC 32 ms
9,140 KB
testcase_39 AC 64 ms
10,004 KB
testcase_40 AC 22 ms
8,936 KB
testcase_41 AC 4 ms
8,012 KB
testcase_42 AC 4 ms
8,172 KB
testcase_43 AC 5 ms
8,304 KB
testcase_44 AC 5 ms
8,040 KB
testcase_45 AC 6 ms
8,028 KB
testcase_46 AC 5 ms
8,012 KB
testcase_47 AC 5 ms
8,064 KB
testcase_48 WA -
testcase_49 AC 6 ms
8,096 KB
testcase_50 AC 5 ms
8,084 KB
testcase_51 AC 4 ms
8,012 KB
testcase_52 AC 4 ms
8,044 KB
testcase_53 WA -
testcase_54 AC 6 ms
8,064 KB
testcase_55 AC 6 ms
8,004 KB
testcase_56 AC 5 ms
8,180 KB
testcase_57 AC 5 ms
8,064 KB
testcase_58 AC 6 ms
8,012 KB
testcase_59 AC 4 ms
8,060 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));
            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