結果

問題 No.844 split game
ユーザー tko919
提出日時 2019-09-04 16:31:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,095 bytes
コンパイル時間 2,329 ms
コンパイル使用メモリ 170,840 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-12-27 19:09:10
合計ジャッジ時間 5,798 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 56
権限があれば一括ダウンロードができます

ソースコード

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