結果
問題 |
No.844 split game
|
ユーザー |
![]() |
提出日時 | 2019-06-28 22:32:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 639 bytes |
コンパイル時間 | 1,604 ms |
コンパイル使用メモリ | 172,876 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-07-02 04:57:03 |
合計ジャッジ時間 | 4,279 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 9 WA * 47 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; template<class T = int> using V = vector<T>; template<class T = int> using VV = V< V<T> >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, m, a; cin >> n >> m >> a; struct S { int l, p; }; VV<S> d(n + 1); while (m--) { int l, r, p; cin >> l >> r >> p, --l; d[r].emplace_back(S{l, p}); } V<lint> dp(n + 1, -1e18); dp[0] = 0; for (int i = 1; i <= n; ++i) { dp[i] = dp[i - 1]; for (S e : d[i]) { dp[i] = max(dp[i], dp[e.l] + e.p - a); } } dp[n] += a; cout << *max_element(begin(dp), end(dp)) << '\n'; }