結果

問題 No.844 split game
ユーザー kk
提出日時 2021-01-25 22:19:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 914 bytes
コンパイル時間 2,439 ms
コンパイル使用メモリ 203,040 KB
実行使用メモリ 9,432 KB
最終ジャッジ日時 2023-09-04 21:24:54
合計ジャッジ時間 7,647 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
7,012 KB
testcase_01 AC 18 ms
7,868 KB
testcase_02 AC 39 ms
7,840 KB
testcase_03 AC 31 ms
8,240 KB
testcase_04 AC 16 ms
6,908 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 AC 52 ms
9,232 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 51 ms
9,200 KB
testcase_19 WA -
testcase_20 AC 51 ms
9,236 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 4 ms
5,964 KB
testcase_27 WA -
testcase_28 AC 4 ms
5,980 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 6 ms
5,936 KB
testcase_34 WA -
testcase_35 AC 7 ms
6,000 KB
testcase_36 AC 6 ms
5,916 KB
testcase_37 AC 9 ms
6,128 KB
testcase_38 AC 15 ms
6,528 KB
testcase_39 AC 29 ms
7,312 KB
testcase_40 AC 13 ms
7,044 KB
testcase_41 AC 3 ms
5,632 KB
testcase_42 AC 4 ms
5,704 KB
testcase_43 AC 4 ms
5,740 KB
testcase_44 AC 3 ms
5,888 KB
testcase_45 AC 3 ms
5,700 KB
testcase_46 WA -
testcase_47 AC 4 ms
5,828 KB
testcase_48 AC 4 ms
5,736 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 4 ms
5,768 KB
testcase_56 AC 4 ms
5,832 KB
testcase_57 AC 4 ms
5,776 KB
testcase_58 AC 3 ms
5,700 KB
testcase_59 AC 3 ms
5,756 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] = 0;
    for (auto &[l, p]: v[i]) {
      // use
      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));

      // not use
      dp[i][0] = max(dp[i][0], dp[i-1][0]);
      dp[i][0] = max(dp[i][0], dp[i-1][1]);
    }
  }

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

  return 0;
}
0