結果
| 問題 |
No.844 split game
|
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2020-01-23 22:52:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 115 ms / 2,000 ms |
| コード長 | 624 bytes |
| コンパイル時間 | 1,669 ms |
| コンパイル使用メモリ | 173,948 KB |
| 実行使用メモリ | 8,448 KB |
| 最終ジャッジ日時 | 2024-07-21 16:48:27 |
| 合計ジャッジ時間 | 7,145 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 56 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
int main(){
int n, m, a;
cin >> n >> m >> a;
vector<vector<P>> v(n+1);
for (int i = 0; i < m; i++) {
int l, r, p;
cin >> l >> r >> p;
v[r].emplace_back(make_pair(l,p));
}
ll res = 0;
vector<ll> dp(n+1,0);
for (int i = 1; i <= n; i++) {
dp[i] = res - a;
for (auto x : v[i]) {
dp[i] = max(dp[i], dp[x.first - 1] + x.second - (i == n ? 0 : a));
}
res = max(res, dp[i]);
}
cout << res << endl;
return 0;
}
iqueue02