結果
問題 |
No.844 split game
|
ユーザー |
![]() |
提出日時 | 2019-03-13 22:38:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 116 ms / 2,000 ms |
コード長 | 620 bytes |
コンパイル時間 | 708 ms |
コンパイル使用メモリ | 72,340 KB |
実行使用メモリ | 9,088 KB |
最終ジャッジ日時 | 2024-06-24 15:04:21 |
合計ジャッジ時間 | 4,748 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 56 |
ソースコード
#include <iostream> #include <vector> #include <cassert> 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; assert(N<=100000 && M<=100000); int l,r; ll p; for(int i=0;i<M;i++){ cin >> l >> r >> p; assert(l<=r); 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; }