結果

問題 No.844 split game
ユーザー ShibuyapShibuyap
提出日時 2020-07-31 05:18:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,077 bytes
コンパイル時間 2,372 ms
コンパイル使用メモリ 206,592 KB
実行使用メモリ 11,712 KB
最終ジャッジ日時 2023-09-19 03:48:04
合計ジャッジ時間 7,381 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
9,384 KB
testcase_01 AC 35 ms
9,664 KB
testcase_02 AC 93 ms
10,728 KB
testcase_03 AC 67 ms
10,316 KB
testcase_04 AC 35 ms
9,140 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 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 WA -
testcase_34 WA -
testcase_35 AC 15 ms
8,384 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 33 ms
9,080 KB
testcase_39 AC 64 ms
10,164 KB
testcase_40 AC 23 ms
9,080 KB
testcase_41 AC 4 ms
8,024 KB
testcase_42 AC 5 ms
8,016 KB
testcase_43 AC 5 ms
8,020 KB
testcase_44 AC 5 ms
8,044 KB
testcase_45 AC 5 ms
8,132 KB
testcase_46 AC 5 ms
8,060 KB
testcase_47 AC 5 ms
8,016 KB
testcase_48 WA -
testcase_49 AC 5 ms
8,220 KB
testcase_50 AC 5 ms
8,032 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 5 ms
8,136 KB
testcase_54 AC 5 ms
8,128 KB
testcase_55 AC 5 ms
8,080 KB
testcase_56 AC 5 ms
8,140 KB
testcase_57 AC 5 ms
8,032 KB
testcase_58 AC 4 ms
8,060 KB
testcase_59 AC 5 ms
8,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,ll> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
vector<P> G[MAX_N];
int main() {
    ll n, m, A;
    cin >> n >> m >> A;
    vector<pair<P,ll>> v;
    rep(i,m){
        int l, r, p;
        cin >> l >> r >> p;
        G[l].push_back(P(r,p));
    }
    rep(i,MAX_N) sort(G[i].begin(), G[i].end());

    ll dp[n+1] = {};
    srep(i,1,n) dp[i] = -A;

    srep(j,1,n+1){
        if(j > 1) dp[j] = max(dp[j-1], dp[j]);
        rep(i,G[j].size()){
            int l = j;
            int r = G[j][i].first;
            ll p = G[j][i].second;
            if(r == n){
                dp[r] = max(dp[r], dp[l-1] + p);
            }else{
                dp[r] = max(dp[r], dp[l-1] + p - A);
            }
        }
    }

        

    ll ans = 0;
    rep(i,n+1) ans = max(ans, dp[i]);

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