結果

問題 No.844 split game
ユーザー snrnsidysnrnsidy
提出日時 2021-10-30 11:51:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,302 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 198,032 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2024-04-16 16:15:19
合計ジャッジ時間 4,892 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
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 WA -
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 7 ms
6,016 KB
testcase_34 AC 5 ms
5,760 KB
testcase_35 AC 8 ms
6,016 KB
testcase_36 AC 6 ms
5,888 KB
testcase_37 AC 9 ms
6,016 KB
testcase_38 AC 15 ms
6,400 KB
testcase_39 AC 28 ms
7,040 KB
testcase_40 AC 12 ms
6,784 KB
testcase_41 AC 4 ms
5,888 KB
testcase_42 AC 4 ms
5,888 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 4 ms
5,760 KB
testcase_53 AC 4 ms
5,888 KB
testcase_54 WA -
testcase_55 AC 4 ms
5,760 KB
testcase_56 AC 4 ms
5,888 KB
testcase_57 AC 4 ms
5,760 KB
testcase_58 AC 4 ms
5,888 KB
testcase_59 AC 4 ms
5,888 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);
                }
                else
                {
                    dp[j] = max(dp[j],get + Max - a);
                }
            }
        }
        Max -= a;
        if(Max <= dp[i])
        {
            Max = dp[i];
            idx = i;
        }
    }

    cout << Max << '\n';

    return 0;
}
0