結果
問題 | No.844 split game |
ユーザー |
|
提出日時 | 2020-04-17 17:16:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 102 ms / 2,000 ms |
コード長 | 921 bytes |
コンパイル時間 | 1,616 ms |
コンパイル使用メモリ | 174,900 KB |
実行使用メモリ | 9,088 KB |
最終ジャッジ日時 | 2024-10-03 10:27:14 |
合計ジャッジ時間 | 5,382 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 56 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using ll = long long ; using P = pair<ll,ll> ; const int INF = 1e9; const int MOD = 1000000007; int main(){ ll n,m,a; cin >> n >> m >> a; vector<vector<P>> section(n+1); rep(i,m){ ll l,r,p; cin >> l >> r >> p; --l;--r; section[r+1].push_back(P(l,p)); } vector<ll> dp(n+1); ll ans = 0; dp[0] = 0; for(int i=1;i<=n;i++){ if(i==n){ dp[i] = ans; for(P s:section[i]){ dp[i] = max(dp[i],dp[s.first] + s.second); } ans = max(ans,dp[i]); continue; } dp[i] = ans - a; for(P s:section[i]){ dp[i] = max(dp[i],dp[s.first] + s.second - a); } ans = max(ans,dp[i]); //cout << dp[i] << endl; } cout << ans << endl; return 0; }