結果

問題 No.844 split game
ユーザー ngtkanangtkana
提出日時 2020-03-29 17:38:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 3,370 ms
コンパイル使用メモリ 204,924 KB
実行使用メモリ 8,916 KB
最終ジャッジ日時 2023-08-30 19:54:14
合計ジャッジ時間 8,272 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
5,168 KB
testcase_01 AC 15 ms
6,752 KB
testcase_02 AC 35 ms
6,656 KB
testcase_03 AC 26 ms
7,472 KB
testcase_04 AC 13 ms
4,904 KB
testcase_05 AC 41 ms
7,864 KB
testcase_06 AC 13 ms
4,960 KB
testcase_07 AC 12 ms
6,332 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 29 ms
5,572 KB
testcase_10 AC 43 ms
7,540 KB
testcase_11 AC 42 ms
8,816 KB
testcase_12 AC 29 ms
5,492 KB
testcase_13 AC 18 ms
4,644 KB
testcase_14 AC 19 ms
6,156 KB
testcase_15 AC 46 ms
8,808 KB
testcase_16 AC 47 ms
8,864 KB
testcase_17 AC 46 ms
8,796 KB
testcase_18 AC 45 ms
8,916 KB
testcase_19 AC 44 ms
8,752 KB
testcase_20 AC 46 ms
8,856 KB
testcase_21 AC 46 ms
8,852 KB
testcase_22 AC 45 ms
8,848 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 4 ms
4,376 KB
testcase_30 AC 4 ms
4,376 KB
testcase_31 AC 4 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 5 ms
4,376 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 5 ms
4,376 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 7 ms
4,376 KB
testcase_38 AC 13 ms
4,380 KB
testcase_39 AC 25 ms
5,608 KB
testcase_40 AC 10 ms
5,428 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 1 ms
4,384 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 1 ms
4,376 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
using real=long double;
void cmx(lint&x,lint y){if(x<y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m,a;std::cin>>n>>m>>a;
    std::vector<std::vector<std::pair<lint,lint>>>g(n+1);
    while(m--){
        lint l,r,p;std::cin>>l>>r>>p;l--;
        g.at(l).emplace_back(r,p);
    }
    std::vector<lint>dp(n+1,-a);
    dp.at(0)=0;
    for(lint i=0,max=0;i<=n;i++){
        cmx(dp.at(i),max-a);
        for(auto&&[j,p]:g.at(i)){
            cmx(dp.at(j),dp.at(i)+p-a);
        }
        cmx(max,dp.at(i));
    }
    std::cout<<dp.at(n)+a<<'\n';
}
0