結果
| 問題 | No.844 split game |
| コンテスト | |
| ユーザー |
tempura_pp
|
| 提出日時 | 2019-03-14 00:35:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,048 bytes |
| 記録 | |
| コンパイル時間 | 1,108 ms |
| コンパイル使用メモリ | 99,396 KB |
| 実行使用メモリ | 14,592 KB |
| 最終ジャッジ日時 | 2024-06-24 14:57:56 |
| 合計ジャッジ時間 | 7,588 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 54 RE * 2 |
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
ll dp[101010][2];
int main(){
ll n,m;
cin>>n>>m;
assert(n>=2&&n<=100000);
assert(2<=m&&m<=100000&&m<=n*(n+1)/2);
ll a;
cin>>a;
assert(1<=a&&a<=1000000000);
vector<pair<int,long long>> v[n];
set<pair<int,int>> st;
rep(i,m){
int x,y,z;
cin>>x>>y>>z;
assert(1<=x&&x<=y&&y<=n);
assert(st.count({x,y})==0);
assert(1<=z&&z<=1000000000);
st.insert({x,y});
--x;--y;
v[y].emplace_back(x,z);
}
rep(i,n){
dp[i+1][0]=max(dp[i][0],dp[i][1]);
dp[i+1][1]=max(dp[i][0],dp[i][1])-a;
for(auto p : v[i]){
dp[i+1][1]=max(dp[i+1][1],dp[p.first][1]+p.second-a);
}
}
cout<<max(dp[n][1]+a,dp[n][0])<<endl;
return 0;
}
tempura_pp