結果

問題 No.844 split game
ユーザー seriru13seriru13
提出日時 2019-09-07 11:22:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,573 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 116,516 KB
実行使用メモリ 8,908 KB
最終ジャッジ日時 2023-09-08 13:31:43
合計ジャッジ時間 4,276 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
5,084 KB
testcase_01 AC 15 ms
6,664 KB
testcase_02 AC 36 ms
6,748 KB
testcase_03 AC 27 ms
7,272 KB
testcase_04 AC 14 ms
4,892 KB
testcase_05 AC 41 ms
7,732 KB
testcase_06 AC 14 ms
4,952 KB
testcase_07 AC 13 ms
6,212 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 29 ms
5,568 KB
testcase_10 AC 43 ms
7,472 KB
testcase_11 AC 43 ms
8,316 KB
testcase_12 AC 28 ms
5,472 KB
testcase_13 AC 18 ms
4,832 KB
testcase_14 AC 20 ms
6,204 KB
testcase_15 AC 46 ms
8,792 KB
testcase_16 AC 46 ms
8,776 KB
testcase_17 AC 47 ms
8,844 KB
testcase_18 AC 47 ms
8,780 KB
testcase_19 AC 47 ms
8,848 KB
testcase_20 AC 46 ms
8,908 KB
testcase_21 AC 45 ms
8,724 KB
testcase_22 AC 45 ms
8,896 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 4 ms
4,376 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 1 ms
4,376 KB
testcase_42 WA -
testcase_43 AC 2 ms
4,376 KB
testcase_44 WA -
testcase_45 AC 1 ms
4,376 KB
testcase_46 WA -
testcase_47 AC 1 ms
4,380 KB
testcase_48 WA -
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 2 ms
4,376 KB
testcase_53 WA -
testcase_54 AC 2 ms
4,376 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<ll,ll>;

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