結果

問題 No.844 split game
ユーザー kk
提出日時 2021-01-25 22:24:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 203,616 KB
実行使用メモリ 9,580 KB
最終ジャッジ日時 2023-09-04 21:30:38
合計ジャッジ時間 5,278 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,040 KB
testcase_01 AC 15 ms
7,940 KB
testcase_02 AC 34 ms
7,864 KB
testcase_03 AC 26 ms
8,256 KB
testcase_04 AC 15 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 14 ms
6,916 KB
testcase_07 AC 13 ms
7,592 KB
testcase_08 WA -
testcase_09 AC 28 ms
7,044 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 28 ms
7,048 KB
testcase_13 AC 19 ms
6,584 KB
testcase_14 WA -
testcase_15 AC 43 ms
9,248 KB
testcase_16 AC 45 ms
9,364 KB
testcase_17 AC 44 ms
9,232 KB
testcase_18 AC 44 ms
9,388 KB
testcase_19 WA -
testcase_20 AC 44 ms
9,484 KB
testcase_21 AC 45 ms
9,280 KB
testcase_22 AC 45 ms
9,220 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 4 ms
5,816 KB
testcase_27 AC 5 ms
5,988 KB
testcase_28 AC 4 ms
5,820 KB
testcase_29 AC 6 ms
6,072 KB
testcase_30 AC 6 ms
6,076 KB
testcase_31 WA -
testcase_32 AC 4 ms
5,868 KB
testcase_33 AC 7 ms
5,880 KB
testcase_34 WA -
testcase_35 AC 7 ms
6,084 KB
testcase_36 AC 6 ms
5,808 KB
testcase_37 AC 8 ms
5,996 KB
testcase_38 AC 14 ms
6,460 KB
testcase_39 AC 27 ms
7,308 KB
testcase_40 AC 11 ms
7,068 KB
testcase_41 AC 4 ms
5,664 KB
testcase_42 AC 4 ms
5,696 KB
testcase_43 AC 4 ms
5,756 KB
testcase_44 AC 4 ms
5,776 KB
testcase_45 AC 3 ms
5,820 KB
testcase_46 AC 3 ms
5,712 KB
testcase_47 AC 3 ms
5,764 KB
testcase_48 AC 4 ms
5,680 KB
testcase_49 AC 3 ms
5,896 KB
testcase_50 AC 3 ms
5,736 KB
testcase_51 AC 4 ms
5,760 KB
testcase_52 AC 3 ms
5,668 KB
testcase_53 WA -
testcase_54 AC 4 ms
5,732 KB
testcase_55 AC 4 ms
5,704 KB
testcase_56 AC 3 ms
5,952 KB
testcase_57 AC 4 ms
5,684 KB
testcase_58 AC 3 ms
5,672 KB
testcase_59 AC 4 ms
5,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

long long dp[100000+1][2];
vector<pair<int, int> > v[100000+1];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m, a;
  cin >> n >> m >> a;

  for (int i = 0; i < m; i++) {
    int l, r, p;
    cin >> l >> r >> p;
    v[r].emplace_back(--l, p);
  }

  for (int i = 0; i <= n; i++)
    for (int j = 0; j < 2; j++)
      dp[i][j] = -1;
  
  dp[0][0] = dp[0][1] = 0;

  for (int i = 1; i <= n; i++) {
    dp[i][0] = max(dp[i-1][0], dp[i-1][1]);
    for (auto &[l, p]: v[i]) {
      if (dp[l][1] >= 0)
        dp[i][1] = max(dp[i][1], dp[l][1] + p - (i == n ? 0 : a));
      dp[i][1] = max(dp[i][1], dp[l][0] + p - (i == n ? a : 2 * a));
    }
  }

  cout << max(dp[n][0], dp[n][1]) << endl;

  return 0;
}
0