結果

問題 No.844 split game
ユーザー risujirohrisujiroh
提出日時 2019-06-28 22:43:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 1,645 ms
コンパイル使用メモリ 170,372 KB
実行使用メモリ 8,072 KB
最終ジャッジ日時 2023-09-14 22:26:17
合計ジャッジ時間 4,902 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
4,836 KB
testcase_01 AC 17 ms
6,684 KB
testcase_02 AC 36 ms
5,936 KB
testcase_03 AC 28 ms
6,716 KB
testcase_04 AC 14 ms
4,596 KB
testcase_05 AC 42 ms
7,236 KB
testcase_06 AC 13 ms
4,804 KB
testcase_07 AC 12 ms
5,884 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 27 ms
4,812 KB
testcase_10 AC 42 ms
6,812 KB
testcase_11 AC 43 ms
7,732 KB
testcase_12 AC 26 ms
4,656 KB
testcase_13 AC 17 ms
4,380 KB
testcase_14 AC 20 ms
5,952 KB
testcase_15 AC 49 ms
7,992 KB
testcase_16 AC 47 ms
7,980 KB
testcase_17 AC 48 ms
8,008 KB
testcase_18 AC 47 ms
8,064 KB
testcase_19 AC 47 ms
8,040 KB
testcase_20 AC 46 ms
7,984 KB
testcase_21 AC 48 ms
8,072 KB
testcase_22 AC 50 ms
8,044 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 4 ms
4,380 KB
testcase_30 AC 5 ms
4,380 KB
testcase_31 AC 4 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 5 ms
4,376 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 7 ms
4,380 KB
testcase_38 AC 13 ms
4,380 KB
testcase_39 AC 27 ms
5,028 KB
testcase_40 AC 11 ms
5,092 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 2 ms
4,376 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 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,380 KB
testcase_59 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m, a; cin >> n >> m >> a;
  struct S { int l, p; };
  VV<S> d(n + 1);
  while (m--) {
    int l, r, p; cin >> l >> r >> p, --l;
    d[r].emplace_back(S{l, p});
  }
  V<lint> dp(n + 1, -1e18);
  dp[0] = 0;
  lint mx = 0;
  for (int i = 1; i <= n; ++i) {
    dp[i] = mx - a;
    for (S e : d[i]) {
      dp[i] = max(dp[i], dp[e.l] + e.p - a);
    }
    mx = max(mx, dp[i]);
  }
  dp[n] += a;
  cout << *max_element(begin(dp), end(dp)) << '\n';
}
0