結果
問題 |
No.844 split game
|
ユーザー |
![]() |
提出日時 | 2020-07-31 05:10:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 949 bytes |
コンパイル時間 | 2,236 ms |
コンパイル使用メモリ | 199,972 KB |
最終ジャッジ日時 | 2025-01-12 08:33:28 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 WA * 23 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair<int,int> P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { ll n, m, A; cin >> n >> m >> A; vector<pair<P,ll>> v; rep(i,m){ pair<P,ll> p; cin >> p.first.first >> p.first.second >> p.second; v.push_back(p); } sort(v.begin(), v.end()); ll dp[n+1] = {}; srep(i,1,n) dp[i] = -A; rep(i,m){ int l = v[i].first.first; int r = v[i].first.second; ll p = v[i].second; if(r == n){ dp[r] = max(dp[r], dp[l-1] + p); }else{ dp[r] = max(dp[r], dp[l-1] + p - A); } } ll ans = 0; rep(i,n+1) ans = max(ans, dp[i]); cout << ans << endl; return 0; }