結果

問題 No.844 split game
ユーザー seriru13seriru13
提出日時 2019-09-07 11:21:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,575 bytes
コンパイル時間 1,217 ms
コンパイル使用メモリ 116,664 KB
実行使用メモリ 8,188 KB
最終ジャッジ日時 2023-09-08 13:30:18
合計ジャッジ時間 6,707 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
4,872 KB
testcase_01 AC 16 ms
6,776 KB
testcase_02 AC 36 ms
5,888 KB
testcase_03 AC 28 ms
6,680 KB
testcase_04 AC 14 ms
4,596 KB
testcase_05 AC 41 ms
7,256 KB
testcase_06 AC 13 ms
4,892 KB
testcase_07 AC 12 ms
5,916 KB
testcase_08 AC 7 ms
4,384 KB
testcase_09 AC 28 ms
4,732 KB
testcase_10 AC 43 ms
6,648 KB
testcase_11 AC 41 ms
7,776 KB
testcase_12 AC 27 ms
4,624 KB
testcase_13 AC 17 ms
4,456 KB
testcase_14 AC 19 ms
5,916 KB
testcase_15 AC 49 ms
8,052 KB
testcase_16 AC 48 ms
8,188 KB
testcase_17 AC 47 ms
7,996 KB
testcase_18 AC 46 ms
7,996 KB
testcase_19 AC 47 ms
7,968 KB
testcase_20 AC 46 ms
7,972 KB
testcase_21 AC 48 ms
8,188 KB
testcase_22 AC 45 ms
8,168 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 5 ms
4,380 KB
testcase_25 WA -
testcase_26 AC 3 ms
4,384 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 2 ms
4,384 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 4 ms
4,380 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
4,380 KB
testcase_42 WA -
testcase_43 AC 1 ms
4,380 KB
testcase_44 WA -
testcase_45 AC 2 ms
4,380 KB
testcase_46 WA -
testcase_47 AC 2 ms
4,380 KB
testcase_48 WA -
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,384 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 WA -
testcase_54 AC 1 ms
4,384 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

// 長さNの線があって、そのうちいくつかの区間に制約があるという状況で何かを最適化する、
// という問題ではDPが有効な場合がある。

using P = pair<int,int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m, a;
    cin >> n >> m >> a;

    vector<vector<P>> v(n+1);
    ll p;
    rep(i, m) {
        int l,r;
        cin >> l >> r >> p;
        v[r].push_back(P(l, p));
    }

    ll ma = 0;
    vector<ll> dp(n+100);
    rep(i, n+1) {
        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