結果

問題 No.844 split game
ユーザー jelljell
提出日時 2019-06-29 10:33:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 1,078 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 170,720 KB
実行使用メモリ 9,356 KB
最終ジャッジ日時 2023-09-14 23:01:36
合計ジャッジ時間 6,663 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
7,572 KB
testcase_01 AC 32 ms
7,936 KB
testcase_02 AC 87 ms
8,312 KB
testcase_03 AC 62 ms
8,352 KB
testcase_04 AC 33 ms
7,340 KB
testcase_05 AC 98 ms
8,868 KB
testcase_06 AC 31 ms
7,328 KB
testcase_07 AC 24 ms
7,560 KB
testcase_08 AC 16 ms
7,208 KB
testcase_09 AC 73 ms
7,856 KB
testcase_10 AC 105 ms
8,640 KB
testcase_11 AC 100 ms
9,040 KB
testcase_12 AC 71 ms
7,732 KB
testcase_13 AC 44 ms
7,312 KB
testcase_14 AC 45 ms
8,096 KB
testcase_15 AC 110 ms
9,192 KB
testcase_16 AC 110 ms
9,188 KB
testcase_17 AC 110 ms
9,356 KB
testcase_18 AC 110 ms
9,184 KB
testcase_19 AC 110 ms
9,220 KB
testcase_20 AC 110 ms
9,152 KB
testcase_21 AC 110 ms
9,232 KB
testcase_22 AC 111 ms
9,232 KB
testcase_23 AC 6 ms
6,648 KB
testcase_24 AC 10 ms
6,840 KB
testcase_25 AC 7 ms
6,484 KB
testcase_26 AC 5 ms
6,508 KB
testcase_27 AC 9 ms
6,836 KB
testcase_28 AC 4 ms
6,564 KB
testcase_29 AC 8 ms
6,748 KB
testcase_30 AC 10 ms
6,704 KB
testcase_31 AC 9 ms
6,672 KB
testcase_32 AC 5 ms
6,600 KB
testcase_33 AC 11 ms
6,896 KB
testcase_34 AC 7 ms
6,524 KB
testcase_35 AC 12 ms
6,864 KB
testcase_36 AC 8 ms
6,552 KB
testcase_37 AC 17 ms
6,860 KB
testcase_38 AC 31 ms
7,136 KB
testcase_39 AC 64 ms
7,908 KB
testcase_40 AC 21 ms
7,416 KB
testcase_41 AC 3 ms
6,468 KB
testcase_42 AC 3 ms
6,432 KB
testcase_43 AC 3 ms
6,596 KB
testcase_44 AC 3 ms
6,420 KB
testcase_45 AC 3 ms
6,516 KB
testcase_46 AC 3 ms
6,384 KB
testcase_47 AC 3 ms
6,416 KB
testcase_48 AC 3 ms
6,488 KB
testcase_49 AC 3 ms
6,560 KB
testcase_50 AC 3 ms
6,664 KB
testcase_51 AC 3 ms
6,408 KB
testcase_52 AC 3 ms
6,520 KB
testcase_53 AC 3 ms
6,428 KB
testcase_54 AC 3 ms
6,480 KB
testcase_55 AC 3 ms
6,724 KB
testcase_56 AC 3 ms
6,412 KB
testcase_57 AC 3 ms
6,468 KB
testcase_58 AC 3 ms
6,540 KB
testcase_59 AC 4 ms
6,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64=int_fast64_t;
using pii=pair<int,int>;
template <class T> constexpr T inf=numeric_limits<T>::max() / (T)2;
template <class T> using minheap=priority_queue<T,vector<T>,greater<T>>;
#define fir first
#define sec second
#define mkp make_pair
#define mkt make_tuple
#define emb emplace_back
#define all(v) begin(v),end(v)
i64 binry(i64 ok, i64 ng, const function<bool(i64)> &f) {
    while(abs(ok-ng)>1) {
        i64 mid=(ok+ng)/2;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

int n,m,A;
vector<pii> segs[1<<17];
i64 dp[1<<17];

signed main() {
    cin>>n>>m>>A;
    for(int i=0; i<m; ++i) {
        int l,r,p; cin>>l>>r>>p;
        segs[r-1].emplace_back(l-1,p);
    }
    fill(dp,dp+n+2,-inf<i64>);
    dp[0]=0;
    for(i64 i=0,rui=0; i<n; ++i) {
        int dec=A;
        if(i==n-1) dec=0;
        dp[1+i]=max(dp[i+1],rui-dec);
        for(auto &s:segs[i]) {
            int l,p; tie(l,p)=s;
            dp[i+1]=max(dp[1+i],dp[l]+p-dec);
        }
        rui=max(rui,dp[i+1]);
    }
    cout<<dp[n]<<"\n";
}
0