結果

問題 No.844 split game
ユーザー tempura_pp
提出日時 2019-03-14 00:47:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 744 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 91,288 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2024-06-24 16:36:06
合計ジャッジ時間 4,930 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 10 WA * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
int main(){
	ll n,m;
	cin>>n>>m;
	ll a;
	cin>>a;
	vector<pair<int,long long>> v[n];
	rep(i,m){
		int x,y,z;
		cin>>x>>y>>z;
		--x;--y;
		if(y!=n-1)z-=a;
		v[y].emplace_back(x,z);
	}
	rep(i,n){
		dp[i+1]=dp[i];
		for(auto p : v[i]){
			dp[i+1]=max(dp[i+1],dp[p.first]+p.second);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}
0