結果

問題 No.844 split game
ユーザー ttttan2ttttan2
提出日時 2019-06-28 22:34:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,398 bytes
コンパイル時間 1,332 ms
コンパイル使用メモリ 153,080 KB
実行使用メモリ 8,592 KB
最終ジャッジ日時 2023-09-14 22:20:06
合計ジャッジ時間 4,709 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
5,460 KB
testcase_01 AC 15 ms
5,804 KB
testcase_02 AC 41 ms
7,448 KB
testcase_03 AC 28 ms
6,892 KB
testcase_04 AC 16 ms
4,960 KB
testcase_05 AC 43 ms
8,040 KB
testcase_06 AC 14 ms
4,752 KB
testcase_07 AC 11 ms
5,216 KB
testcase_08 AC 7 ms
4,376 KB
testcase_09 AC 35 ms
6,672 KB
testcase_10 AC 46 ms
7,956 KB
testcase_11 AC 44 ms
8,216 KB
testcase_12 AC 35 ms
6,640 KB
testcase_13 AC 21 ms
5,052 KB
testcase_14 AC 20 ms
5,572 KB
testcase_15 AC 48 ms
8,592 KB
testcase_16 AC 48 ms
8,440 KB
testcase_17 AC 47 ms
8,580 KB
testcase_18 AC 48 ms
8,520 KB
testcase_19 AC 48 ms
8,460 KB
testcase_20 AC 48 ms
8,428 KB
testcase_21 AC 48 ms
8,576 KB
testcase_22 AC 48 ms
8,432 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 4 ms
4,376 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 4 ms
4,380 KB
testcase_30 AC 5 ms
4,380 KB
testcase_31 AC 4 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 6 ms
4,380 KB
testcase_34 AC 4 ms
4,380 KB
testcase_35 AC 7 ms
4,380 KB
testcase_36 AC 5 ms
4,380 KB
testcase_37 AC 10 ms
4,376 KB
testcase_38 AC 13 ms
4,928 KB
testcase_39 AC 27 ms
6,628 KB
testcase_40 AC 9 ms
4,896 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,a;cin>>n>>m>>a;
    vector<pll> v;
    ll l[m],r[m],p[m];
    rep(i,0,m){
        cin>>l[i]>>r[i]>>p[i];
        v.push_back(make_pair(l[i],i));
    }
    sort(v.begin(),v.end());
    ll dp[n+3][2];
    rep(i,0,n+3){
        rep(j,0,2)dp[i][j]=-inf;
    }
    int now=0;
    dp[0][1]=0;
    rep(i,1,n+1){
        dp[i][0]=max(max(dp[i-1][1],dp[i-1][0]),dp[i][0]);
        while(now<m&&v[now].first==i){
            //cout<<i<<endl;
            ll nr=r[v[now].second],np=p[v[now].second];
            int u;
            if(nr==n)u=0;
            else u=a;
            dp[nr][1]=max(dp[nr][1],dp[i-1][1]+np-u);
            dp[nr][1]=max(dp[nr][1],dp[i-1][0]+np-a-u);
            now++;
        }
    }
    cout<<max((ll)0,max(dp[n][0],dp[n][1]))<<endl;
    
}
0