結果

問題 No.844 split game
ユーザー sinsincoscossinsincoscos
提出日時 2019-03-13 22:08:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 71,664 KB
実行使用メモリ 9,092 KB
最終ジャッジ日時 2023-09-06 20:35:32
合計ジャッジ時間 5,026 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
6,980 KB
testcase_01 AC 32 ms
7,012 KB
testcase_02 AC 86 ms
8,296 KB
testcase_03 AC 59 ms
7,460 KB
testcase_04 AC 32 ms
6,468 KB
testcase_05 AC 96 ms
8,288 KB
testcase_06 AC 31 ms
6,504 KB
testcase_07 AC 24 ms
6,716 KB
testcase_08 AC 17 ms
5,996 KB
testcase_09 AC 72 ms
7,572 KB
testcase_10 AC 105 ms
8,368 KB
testcase_11 AC 100 ms
8,660 KB
testcase_12 AC 72 ms
7,600 KB
testcase_13 AC 46 ms
6,696 KB
testcase_14 AC 44 ms
6,944 KB
testcase_15 AC 112 ms
8,896 KB
testcase_16 AC 109 ms
8,832 KB
testcase_17 AC 110 ms
9,092 KB
testcase_18 AC 110 ms
8,872 KB
testcase_19 AC 111 ms
8,924 KB
testcase_20 AC 110 ms
8,796 KB
testcase_21 AC 109 ms
8,840 KB
testcase_22 AC 109 ms
8,876 KB
testcase_23 AC 6 ms
5,376 KB
testcase_24 AC 10 ms
5,628 KB
testcase_25 AC 7 ms
5,184 KB
testcase_26 AC 4 ms
5,188 KB
testcase_27 AC 9 ms
5,692 KB
testcase_28 AC 4 ms
5,184 KB
testcase_29 AC 8 ms
5,776 KB
testcase_30 AC 10 ms
5,660 KB
testcase_31 AC 9 ms
5,708 KB
testcase_32 AC 5 ms
5,316 KB
testcase_33 AC 11 ms
5,672 KB
testcase_34 AC 8 ms
5,924 KB
testcase_35 AC 12 ms
5,772 KB
testcase_36 AC 9 ms
5,608 KB
testcase_37 AC 17 ms
6,024 KB
testcase_38 AC 32 ms
6,756 KB
testcase_39 AC 65 ms
7,724 KB
testcase_40 AC 20 ms
6,408 KB
testcase_41 AC 3 ms
5,120 KB
testcase_42 AC 4 ms
5,336 KB
testcase_43 AC 4 ms
5,384 KB
testcase_44 AC 4 ms
5,236 KB
testcase_45 AC 3 ms
5,244 KB
testcase_46 AC 3 ms
5,240 KB
testcase_47 AC 3 ms
5,404 KB
testcase_48 AC 3 ms
5,232 KB
testcase_49 AC 2 ms
5,368 KB
testcase_50 AC 4 ms
5,228 KB
testcase_51 AC 3 ms
5,376 KB
testcase_52 AC 3 ms
5,276 KB
testcase_53 AC 3 ms
5,376 KB
testcase_54 AC 2 ms
5,308 KB
testcase_55 AC 3 ms
5,300 KB
testcase_56 AC 4 ms
5,296 KB
testcase_57 AC 3 ms
5,412 KB
testcase_58 AC 3 ms
5,372 KB
testcase_59 AC 3 ms
5,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
int N,M;
ll A,dp[100010] = {};
vector<vector<P>> v(100010);

int main(){
    cin >> N >> M >> A;
    int l,r;
    ll p;
    for(int i=0;i<M;i++){
        cin >> l >> r >> p;
        v[r].push_back(P(l,p));
    }
    ll ma = 0;
    for(int i=1;i<=N;i++){
        dp[i] = ma-A;
        for(auto x:v[i]){
            dp[i] = max(dp[i],dp[x.first-1]+x.second-(i==N? 0:A));
        }
        ma = max(ma,dp[i]);
    }
    cout << ma << endl;
}
0