結果

問題 No.844 split game
ユーザー totori_nyaatotori_nyaa
提出日時 2019-08-06 16:18:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 642 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 173,008 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2024-07-18 14:05:31
合計ジャッジ時間 4,061 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

 
signed main(){
    //cout << setprecision(12) ;
    ios::sync_with_stdio(false);
	cin.tie(0);

    ll n,m,a;
    cin>>n>>m>>a;
    vector<vector<pair<ll,ll>>> v(111111);
    for(ll i=0;i<m;i++){
        ll l,r,c;
        cin>>l>>r>>c;
        l--;
        v[r].push_back(make_pair(l,c));
    }
    vector<ll> dp(n+1,-a);
    dp[0]=0,dp[n]=0;
    ll ans=0;
    for(ll i=0;i<=n;i++){
        ll ret=0;
        for(auto j:v[i]){
            ret = max(ret,dp[j.first]+j.second);
        }
        dp[i] += ret;
        ans = max(ans,dp[i]);
    }
    cout<<ans<<endl;


    
}
0