結果

問題 No.844 split game
ユーザー tko919tko919
提出日時 2019-09-04 16:31:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,095 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 170,112 KB
実行使用メモリ 8,984 KB
最終ジャッジ日時 2023-08-27 16:30:35
合計ジャッジ時間 6,271 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,416 KB
testcase_01 AC 14 ms
7,028 KB
testcase_02 AC 34 ms
8,672 KB
testcase_03 AC 26 ms
7,756 KB
testcase_04 AC 15 ms
7,084 KB
testcase_05 AC 39 ms
8,612 KB
testcase_06 AC 14 ms
7,064 KB
testcase_07 AC 11 ms
6,756 KB
testcase_08 AC 7 ms
6,508 KB
testcase_09 AC 28 ms
8,196 KB
testcase_10 AC 39 ms
8,608 KB
testcase_11 AC 37 ms
8,780 KB
testcase_12 AC 26 ms
8,348 KB
testcase_13 AC 19 ms
7,404 KB
testcase_14 AC 17 ms
7,164 KB
testcase_15 AC 41 ms
8,912 KB
testcase_16 AC 38 ms
8,920 KB
testcase_17 AC 40 ms
8,864 KB
testcase_18 AC 41 ms
8,888 KB
testcase_19 AC 40 ms
8,984 KB
testcase_20 AC 40 ms
8,904 KB
testcase_21 AC 40 ms
8,868 KB
testcase_22 AC 39 ms
8,928 KB
testcase_23 AC 5 ms
6,232 KB
testcase_24 AC 6 ms
6,444 KB
testcase_25 AC 5 ms
6,292 KB
testcase_26 AC 4 ms
6,344 KB
testcase_27 AC 5 ms
6,464 KB
testcase_28 AC 3 ms
6,296 KB
testcase_29 AC 6 ms
6,612 KB
testcase_30 AC 6 ms
6,544 KB
testcase_31 AC 5 ms
6,600 KB
testcase_32 AC 4 ms
6,332 KB
testcase_33 AC 6 ms
6,556 KB
testcase_34 AC 4 ms
6,376 KB
testcase_35 AC 7 ms
6,612 KB
testcase_36 AC 5 ms
6,500 KB
testcase_37 AC 8 ms
6,816 KB
testcase_38 AC 14 ms
7,292 KB
testcase_39 AC 26 ms
8,604 KB
testcase_40 AC 10 ms
6,876 KB
testcase_41 AC 3 ms
6,184 KB
testcase_42 AC 3 ms
6,232 KB
testcase_43 AC 4 ms
6,336 KB
testcase_44 AC 4 ms
6,348 KB
testcase_45 AC 3 ms
6,168 KB
testcase_46 AC 3 ms
6,236 KB
testcase_47 AC 4 ms
6,188 KB
testcase_48 AC 3 ms
6,336 KB
testcase_49 AC 3 ms
6,292 KB
testcase_50 AC 3 ms
6,168 KB
testcase_51 AC 3 ms
6,184 KB
testcase_52 AC 3 ms
6,348 KB
testcase_53 AC 3 ms
6,268 KB
testcase_54 AC 4 ms
6,232 KB
testcase_55 AC 3 ms
6,352 KB
testcase_56 AC 3 ms
6,280 KB
testcase_57 AC 3 ms
6,244 KB
testcase_58 AC 3 ms
6,348 KB
testcase_59 AC 3 ms
6,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,m,a; scanf("%d%d%d",&n,&m,&a);
    ll dp[100010]={}; vector<vector<P>> vec(100010);
    rep(i,0,m){
        int l,r,p; scanf("%d%d%d",&l,&r,&p);
        vec[r].push_back({l,p});
    }
    ll maxx=0;
    rep(i,1,n+1){
        dp[i]=maxx-a;
        for(P p:vec[i]){
            int l=p.first,w=p.second;
            chmax(dp[i],dp[l-1]+w-(i==n?0:a));
        }
        chmax(maxx,dp[i]);
    }
    printf("%lld\n",maxx);
    return 0;
}
0