結果

問題 No.844 split game
ユーザー MayimgMayimg
提出日時 2019-06-30 03:02:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 748 bytes
コンパイル時間 2,140 ms
コンパイル使用メモリ 205,204 KB
実行使用メモリ 9,008 KB
最終ジャッジ日時 2023-09-17 15:55:20
合計ジャッジ時間 7,107 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
5,120 KB
testcase_01 AC 17 ms
7,500 KB
testcase_02 AC 35 ms
6,100 KB
testcase_03 AC 28 ms
7,496 KB
testcase_04 AC 14 ms
4,968 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 48 ms
8,800 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 48 ms
8,856 KB
testcase_19 WA -
testcase_20 AC 49 ms
8,996 KB
testcase_21 AC 49 ms
8,880 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 3 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 4 ms
4,384 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
4,380 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 5 ms
4,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 13 ms
4,376 KB
testcase_39 AC 27 ms
5,052 KB
testcase_40 AC 11 ms
5,736 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 WA -
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 1 ms
4,384 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0); 
  int n, m, a;
  cin >> n >> m >> a;
  vector<vector<pair<int, int>>> rr(n + 1);
  for (int i = 0; i < m; i++) {
    int l, r, p;
    cin >> l >> r >> p;
    rr[r].emplace_back(l - 1, p);
  }
  vector<long long> dp(n + 1), s(n + 1);
  s[0] = 1;
  s[n] = 1;
  for (int r = 1; r <= n; r++) {
    dp[r] = max(dp[r - 1], dp[r]);
    long long tmp = dp[r];
    for (auto i : rr[r]) {
      int l = i.first;
      long long p = i.second;
      long long t = dp[l] + p - (r == n ? 0 : 1) * a;
      dp[r] = max(dp[r], t - (s[l] ? 0 : 1) * a);
    }
    if (dp[r] > tmp) s[r] = 1;
  }
  cout << dp[n] << endl;
  return 0;
}
0