結果

問題 No.844 split game
ユーザー ttttan2ttttan2
提出日時 2019-06-28 22:23:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,369 bytes
コンパイル時間 1,264 ms
コンパイル使用メモリ 149,440 KB
実行使用メモリ 8,840 KB
最終ジャッジ日時 2023-09-14 22:10:17
合計ジャッジ時間 4,549 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
5,316 KB
testcase_01 AC 12 ms
5,932 KB
testcase_02 AC 30 ms
7,448 KB
testcase_03 AC 22 ms
6,956 KB
testcase_04 AC 12 ms
5,140 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 36 ms
8,572 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 36 ms
8,460 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 12 ms
4,944 KB
testcase_39 AC 24 ms
6,644 KB
testcase_40 AC 9 ms
4,816 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 1 ms
4,376 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
権限があれば一括ダウンロードができます

ソースコード

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));
    }
    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