結果

問題 No.844 split game
コンテスト
ユーザー chocorusk
提出日時 2019-06-28 21:44:05
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 908 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 619 ms
コンパイル使用メモリ 130,264 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2026-03-23 08:13:58
合計ジャッジ時間 3,500 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
    for(int i=1; i<=n; i++){
        for(auto p:v[i]){
            dp[i]=max(dp[i], dp[p.first-1]-a+p.second);
        }
      ans=max(dp[i], ans);
    }
  ans=max(ans, dp[n]+a);
    cout<<ans<<endl;
    return 0;
}
0