結果
問題 | No.844 split game |
ユーザー |
![]() |
提出日時 | 2019-03-13 22:08:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 114 ms / 2,000 ms |
コード長 | 543 bytes |
コンパイル時間 | 662 ms |
コンパイル使用メモリ | 73,148 KB |
実行使用メモリ | 8,996 KB |
最終ジャッジ日時 | 2024-06-24 14:58:06 |
合計ジャッジ時間 | 4,732 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 56 |
ソースコード
#include <iostream> #include <vector> using namespace std; typedef long long ll; typedef pair<int,ll> P; int N,M; ll A,dp[100010] = {}; vector<vector<P>> v(100010); int main(){ cin >> N >> M >> A; int l,r; ll p; for(int i=0;i<M;i++){ cin >> l >> r >> p; v[r].push_back(P(l,p)); } ll ma = 0; for(int i=1;i<=N;i++){ dp[i] = ma-A; for(auto x:v[i]){ dp[i] = max(dp[i],dp[x.first-1]+x.second-(i==N? 0:A)); } ma = max(ma,dp[i]); } cout << ma << endl; }