結果

問題 No.844 split game
ユーザー totori_nyaatotori_nyaa
提出日時 2019-08-06 16:39:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 171,652 KB
実行使用メモリ 9,272 KB
最終ジャッジ日時 2023-09-25 17:54:06
合計ジャッジ時間 5,016 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
6,988 KB
testcase_01 AC 16 ms
7,340 KB
testcase_02 AC 38 ms
8,228 KB
testcase_03 AC 28 ms
7,940 KB
testcase_04 AC 16 ms
6,636 KB
testcase_05 AC 41 ms
8,492 KB
testcase_06 AC 14 ms
6,664 KB
testcase_07 AC 13 ms
6,648 KB
testcase_08 AC 8 ms
6,372 KB
testcase_09 AC 31 ms
7,900 KB
testcase_10 AC 44 ms
8,516 KB
testcase_11 AC 45 ms
8,928 KB
testcase_12 AC 29 ms
7,872 KB
testcase_13 AC 20 ms
6,908 KB
testcase_14 AC 21 ms
7,220 KB
testcase_15 AC 48 ms
9,052 KB
testcase_16 AC 48 ms
9,092 KB
testcase_17 AC 49 ms
9,244 KB
testcase_18 AC 48 ms
9,024 KB
testcase_19 AC 48 ms
9,044 KB
testcase_20 AC 45 ms
8,952 KB
testcase_21 AC 48 ms
9,272 KB
testcase_22 AC 48 ms
9,036 KB
testcase_23 AC 4 ms
5,876 KB
testcase_24 AC 7 ms
6,088 KB
testcase_25 AC 5 ms
5,996 KB
testcase_26 AC 4 ms
5,760 KB
testcase_27 AC 5 ms
5,920 KB
testcase_28 AC 4 ms
5,840 KB
testcase_29 AC 5 ms
6,000 KB
testcase_30 AC 5 ms
6,084 KB
testcase_31 AC 5 ms
5,900 KB
testcase_32 AC 3 ms
5,676 KB
testcase_33 AC 6 ms
6,116 KB
testcase_34 AC 6 ms
6,108 KB
testcase_35 AC 8 ms
6,220 KB
testcase_36 AC 5 ms
5,972 KB
testcase_37 AC 10 ms
6,352 KB
testcase_38 AC 15 ms
6,964 KB
testcase_39 AC 30 ms
8,112 KB
testcase_40 AC 12 ms
6,776 KB
testcase_41 AC 4 ms
5,520 KB
testcase_42 AC 3 ms
5,496 KB
testcase_43 AC 3 ms
5,600 KB
testcase_44 AC 3 ms
5,648 KB
testcase_45 AC 4 ms
5,560 KB
testcase_46 AC 3 ms
5,636 KB
testcase_47 AC 4 ms
5,724 KB
testcase_48 AC 3 ms
5,736 KB
testcase_49 AC 3 ms
5,600 KB
testcase_50 AC 3 ms
5,604 KB
testcase_51 AC 4 ms
5,724 KB
testcase_52 AC 3 ms
5,560 KB
testcase_53 AC 3 ms
5,592 KB
testcase_54 AC 3 ms
5,584 KB
testcase_55 AC 3 ms
5,632 KB
testcase_56 AC 4 ms
5,564 KB
testcase_57 AC 3 ms
5,600 KB
testcase_58 AC 3 ms
5,584 KB
testcase_59 AC 4 ms
5,760 KB
権限があれば一括ダウンロードができます

ソースコード

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=-1e18;
    
    for(ll i=1;i<=n;i++){
        ll ret=0;
        for(auto j:v[i]){
            ret = max(ret,dp[j.first]+j.second);
        }
        dp[i] = max(dp[i]+ret,ans-a);
        ans = max(ans,dp[i]);
        
    }
    ans = max(ans,0LL);
    cout<<ans<<endl;


    
}
0