結果

問題 No.844 split game
ユーザー snrnsidysnrnsidy
提出日時 2021-10-30 11:46:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,289 bytes
コンパイル時間 2,257 ms
コンパイル使用メモリ 199,084 KB
実行使用メモリ 8,812 KB
最終ジャッジ日時 2024-04-16 16:15:13
合計ジャッジ時間 5,855 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
7,040 KB
testcase_01 AC 17 ms
7,168 KB
testcase_02 AC 39 ms
7,736 KB
testcase_03 AC 29 ms
7,936 KB
testcase_04 AC 16 ms
6,656 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 46 ms
8,704 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 49 ms
8,576 KB
testcase_19 WA -
testcase_20 AC 49 ms
8,576 KB
testcase_21 AC 51 ms
8,700 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 4 ms
6,016 KB
testcase_27 WA -
testcase_28 AC 4 ms
6,016 KB
testcase_29 AC 6 ms
6,272 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 4 ms
6,016 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 8 ms
6,144 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 15 ms
6,528 KB
testcase_39 AC 26 ms
6,912 KB
testcase_40 AC 11 ms
6,784 KB
testcase_41 AC 4 ms
6,016 KB
testcase_42 AC 4 ms
6,016 KB
testcase_43 AC 4 ms
6,016 KB
testcase_44 AC 4 ms
5,888 KB
testcase_45 AC 3 ms
5,760 KB
testcase_46 AC 3 ms
5,888 KB
testcase_47 AC 4 ms
6,016 KB
testcase_48 AC 3 ms
6,016 KB
testcase_49 AC 3 ms
6,016 KB
testcase_50 AC 4 ms
6,016 KB
testcase_51 AC 2 ms
6,016 KB
testcase_52 AC 3 ms
5,888 KB
testcase_53 WA -
testcase_54 AC 3 ms
5,888 KB
testcase_55 AC 4 ms
5,760 KB
testcase_56 AC 4 ms
5,888 KB
testcase_57 AC 3 ms
6,016 KB
testcase_58 AC 3 ms
5,888 KB
testcase_59 AC 4 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector <pair<int,int>> adj[100005];
long long int dp[100005];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m,a,l,r,p;

    cin >> n >> m >> a;

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

    for(int i=0;i<=n;i++)
    {
        dp[i] = -1e18;
    }

    dp[0] = 0;

    long long int Max = 0;
    int idx = 0;

    for(int i=1;i<=n;i++)
    {
        for(auto it : adj[i])
        {
            int j = it.first;
            int get = it.second;
            if(idx==i-1)
            {
                if(j==n)
                {
                    dp[j] = max(dp[j],get + Max);
                }
                else
                {
                    dp[j] = max(dp[j],get + Max - a);
                }
            }
            else
            {
                if(j==n)
                {
                    dp[j] = max(dp[j], get + Max - a);
                }
                else
                {
                    dp[j] = max(dp[j],get + Max - 2*a);
                }
            }
        }
        if(Max <= dp[i])
        {
            Max = dp[i];
            idx = i;
        }
    }

    cout << Max << '\n';

    return 0;
}
0