結果

問題 No.844 split game
ユーザー ShibuyapShibuyap
提出日時 2020-07-31 05:10:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 949 bytes
コンパイル時間 4,401 ms
コンパイル使用メモリ 206,528 KB
実行使用メモリ 5,648 KB
最終ジャッジ日時 2023-09-19 03:27:22
合計ジャッジ時間 11,150 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
4,380 KB
testcase_01 AC 29 ms
4,380 KB
testcase_02 AC 85 ms
5,336 KB
testcase_03 AC 58 ms
4,824 KB
testcase_04 AC 31 ms
4,376 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 103 ms
5,396 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 103 ms
5,484 KB
testcase_19 AC 104 ms
5,384 KB
testcase_20 AC 103 ms
5,340 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 3 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 7 ms
4,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 10 ms
4,376 KB
testcase_34 AC 7 ms
4,380 KB
testcase_35 AC 13 ms
4,380 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 18 ms
4,376 KB
testcase_38 AC 29 ms
4,380 KB
testcase_39 AC 59 ms
5,216 KB
testcase_40 AC 18 ms
4,380 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 WA -
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, m, A;
    cin >> n >> m >> A;
    vector<pair<P,ll>> v;
    rep(i,m){
        pair<P,ll> p;
        cin >> p.first.first >> p.first.second >> p.second;
        v.push_back(p);
    }
    sort(v.begin(), v.end());

    ll dp[n+1] = {};
    srep(i,1,n) dp[i] = -A;

    rep(i,m){
        int l = v[i].first.first;
        int r = v[i].first.second;
        ll p = v[i].second;
        if(r == n){
            dp[r] = max(dp[r], dp[l-1] + p);
        }else{
            dp[r] = max(dp[r], dp[l-1] + p - A);
        }
    }

    ll ans = 0;
    rep(i,n+1) ans = max(ans, dp[i]);

    cout << ans << endl;
    return 0;
}
 
 
0