結果
| 問題 | No.844 split game | 
| コンテスト | |
| ユーザー |  chocorusk | 
| 提出日時 | 2019-06-28 21:49:58 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 122 ms / 2,000 ms | 
| コード長 | 1,009 bytes | 
| コンパイル時間 | 895 ms | 
| コンパイル使用メモリ | 102,216 KB | 
| 実行使用メモリ | 9,984 KB | 
| 最終ジャッジ日時 | 2024-07-02 04:37:10 | 
| 合計ジャッジ時間 | 4,976 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 56 | 
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;
int main()
{
    int n, m; ll a; cin>>n>>m>>a;
    ll dp[100010];
    fill(dp, dp+n+1, -a);
    dp[0]=0;
    vector<P> v[100010];
    for(int i=0; i<m; i++){
        int l, r; ll p; cin>>l>>r>>p;
        v[r].push_back({l, p});
    }
  ll ans=0;
  ll mx[100010];
  mx[0]=0;
    for(int i=1; i<=n; i++){
        for(auto p:v[i]){
            dp[i]=max({dp[i], dp[p.first-1]-a+p.second, mx[max(p.first-2, 0)]-2*a+p.second});
        }
        mx[i]=max(mx[i-1], dp[i]);
      ans=max(dp[i], ans);
    }
  ans=max(ans, dp[n]+a);
    cout<<ans<<endl;
    return 0;
}
            
            
            
        