結果
| 問題 |
No.844 split game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-17 17:05:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 914 bytes |
| コンパイル時間 | 1,478 ms |
| コンパイル使用メモリ | 173,920 KB |
| 実行使用メモリ | 9,088 KB |
| 最終ジャッジ日時 | 2024-10-03 10:26:46 |
| 合計ジャッジ時間 | 6,258 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 WA * 23 |
ソースコード
#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] = 0;
for(P s:section[i]){
dp[i] = max(dp[i],dp[s.first] + s.second);
}
ans = max(ans,dp[i]);
continue;
}
dp[i] = -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;
}