結果

問題 No.844 split game
ユーザー t33ft33f
提出日時 2019-06-29 00:22:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 82,820 KB
実行使用メモリ 14,896 KB
最終ジャッジ日時 2023-09-14 22:50:43
合計ジャッジ時間 6,185 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
7,420 KB
testcase_01 AC 66 ms
12,836 KB
testcase_02 AC 125 ms
8,748 KB
testcase_03 AC 104 ms
12,028 KB
testcase_04 AC 47 ms
7,200 KB
testcase_05 AC 153 ms
12,644 KB
testcase_06 AC 43 ms
7,408 KB
testcase_07 AC 48 ms
11,188 KB
testcase_08 AC 23 ms
6,100 KB
testcase_09 AC 91 ms
5,944 KB
testcase_10 AC 156 ms
11,100 KB
testcase_11 AC 162 ms
14,236 KB
testcase_12 AC 83 ms
5,528 KB
testcase_13 AC 52 ms
5,156 KB
testcase_14 AC 69 ms
10,220 KB
testcase_15 AC 180 ms
14,704 KB
testcase_16 AC 180 ms
14,724 KB
testcase_17 AC 176 ms
14,712 KB
testcase_18 AC 173 ms
14,896 KB
testcase_19 AC 177 ms
14,708 KB
testcase_20 AC 175 ms
14,708 KB
testcase_21 AC 174 ms
14,708 KB
testcase_22 AC 178 ms
14,704 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 11 ms
4,508 KB
testcase_25 AC 6 ms
4,380 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 8 ms
4,380 KB
testcase_28 AC 4 ms
4,384 KB
testcase_29 AC 10 ms
4,480 KB
testcase_30 AC 11 ms
4,648 KB
testcase_31 AC 8 ms
4,376 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 10 ms
4,376 KB
testcase_34 AC 6 ms
4,376 KB
testcase_35 AC 12 ms
4,376 KB
testcase_36 AC 8 ms
4,380 KB
testcase_37 AC 17 ms
4,380 KB
testcase_38 AC 37 ms
4,832 KB
testcase_39 AC 82 ms
6,380 KB
testcase_40 AC 37 ms
8,792 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 ms
4,376 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <map>
#include <iostream>
using namespace std;
int main() {
    int n, m, a; cin >> n >> m >> a;
    map<int, vector<pair<int, int> > > mp;
    for (int i = 0; i < m; i++) {
        int l, r, p; cin >> l >> r >> p;
        mp[r].push_back({l, p});
    }
    long long dp[n+1], acc[n+1];
    dp[0] = acc[0] = 0;
    for (int x = 1; x <= n; x++) {
        long long val = -(1LL<<60);
        int cost = x == n ? 0 : a;
        for (auto interval : mp[x]) {
            int l = interval.first, p = interval.second;
            val = max(val, acc[l-1] + p - cost - a);
            val = max(val, dp[l-1] + p - cost);
        }
        dp[x] = val;
        acc[x] = max(acc[x-1], dp[x]);
        // cerr << x << ' ' << dp[x] << ' ' << acc[x] << endl;
    }
    cout << acc[n] << endl;
}
0