結果

問題 No.844 split game
ユーザー simansiman
提出日時 2023-07-27 18:16:08
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,163 bytes
コンパイル時間 1,066 ms
コンパイル使用メモリ 141,616 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2024-04-15 05:16:43
合計ジャッジ時間 5,795 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
6,816 KB
testcase_01 AC 34 ms
7,168 KB
testcase_02 AC 90 ms
6,940 KB
testcase_03 AC 67 ms
7,424 KB
testcase_04 AC 34 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 11 ms
6,944 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 30 ms
6,944 KB
testcase_39 AC 60 ms
6,940 KB
testcase_40 AC 20 ms
6,944 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 1 ms
6,944 KB
testcase_43 AC 2 ms
6,940 KB
testcase_44 AC 1 ms
6,940 KB
testcase_45 AC 2 ms
6,944 KB
testcase_46 AC 2 ms
6,940 KB
testcase_47 AC 2 ms
6,940 KB
testcase_48 WA -
testcase_49 AC 2 ms
6,940 KB
testcase_50 AC 1 ms
6,944 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1 ms
6,944 KB
testcase_54 AC 2 ms
6,940 KB
testcase_55 AC 1 ms
6,944 KB
testcase_56 AC 1 ms
6,944 KB
testcase_57 AC 2 ms
6,940 KB
testcase_58 AC 2 ms
6,944 KB
testcase_59 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

struct Range {
  int l;
  int r;
  ll p;

  Range(int l = -1, int r = -1, ll p = 0) {
    this->l = l;
    this->r = r;
    this->p = p;
  }
};

int main() {
  int N, M;
  ll A;
  cin >> N >> M >> A;

  vector<Range> range_list[N + 1];
  for (int i = 0; i < M; ++i) {
    Range range;
    cin >> range.l >> range.r >> range.p;

    range_list[range.l].push_back(range);
  }

  ll dp[N + 2];
  memset(dp, 0, sizeof(dp));

  for (int i = 1; i <= N; ++i) {
    dp[i] = max(dp[i], dp[i - 1]);

    for (Range &range : range_list[i]) {
      if (range.l == 1) {
        dp[range.r + 1] = max(dp[range.r + 1], dp[i] + range.p);
      } else {
        dp[range.r + 1] = max(dp[range.r + 1], dp[i] + range.p - A);
      }
    }
  }

  ll ans = 0;

  for (int i = 1; i <= N + 1; ++i) {
    if (i <= N) {
      ans = max(ans, dp[i] - A);
    } else {
      ans = max(ans, dp[i]);
    }
  }

  cout << ans << endl;

  return 0;
}
0