結果

問題 No.844 split game
ユーザー ninjaninja
提出日時 2019-06-28 23:46:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 1,778 ms
コンパイル使用メモリ 149,272 KB
実行使用メモリ 8,872 KB
最終ジャッジ日時 2023-09-14 22:46:33
合計ジャッジ時間 5,162 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
5,096 KB
testcase_01 AC 17 ms
6,764 KB
testcase_02 AC 40 ms
6,684 KB
testcase_03 AC 30 ms
7,412 KB
testcase_04 AC 15 ms
4,956 KB
testcase_05 AC 45 ms
7,820 KB
testcase_06 AC 14 ms
4,888 KB
testcase_07 AC 13 ms
5,888 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 31 ms
5,492 KB
testcase_10 AC 48 ms
7,472 KB
testcase_11 AC 46 ms
8,444 KB
testcase_12 AC 28 ms
5,544 KB
testcase_13 AC 19 ms
4,720 KB
testcase_14 AC 20 ms
6,260 KB
testcase_15 AC 52 ms
8,808 KB
testcase_16 AC 52 ms
8,872 KB
testcase_17 AC 52 ms
8,792 KB
testcase_18 AC 51 ms
8,796 KB
testcase_19 AC 51 ms
8,848 KB
testcase_20 AC 51 ms
8,724 KB
testcase_21 AC 51 ms
8,852 KB
testcase_22 AC 52 ms
8,844 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 5 ms
4,376 KB
testcase_30 AC 4 ms
4,380 KB
testcase_31 AC 4 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 5 ms
4,376 KB
testcase_34 AC 4 ms
4,376 KB
testcase_35 AC 5 ms
4,380 KB
testcase_36 AC 4 ms
4,376 KB
testcase_37 AC 8 ms
4,380 KB
testcase_38 AC 14 ms
4,600 KB
testcase_39 AC 29 ms
6,172 KB
testcase_40 AC 11 ms
5,468 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2 ms
4,384 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 1 ms
4,384 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll dp[101010] = {0};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, a;
  cin >> n >> m >> a;

  vector<vector<pair<ll, ll>>> ps(n + 1);
  for (int i = 0; i < m; i++) {
    ll l, r, c;
    cin >> l >> r >> c;
    ps[r].emplace_back(l - 1, c);
  }
  dp[0] = 0;
  ll summax = 0;
  for (int i = 1; i <= n; i++) {
    dp[i] = summax - (i == n ? 0 : a);
    for (auto &v : ps[i]) {
      dp[i] = max(dp[i], dp[v.first] + v.second - (i == n ? 0 : a));
    }
    summax = max(summax, dp[i]);
  }
  cout << summax << endl;

  return 0;
}
0