結果

問題 No.844 split game
ユーザー 👑 kmjpkmjp
提出日時 2019-06-29 00:39:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,006 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 168,496 KB
実行使用メモリ 8,820 KB
最終ジャッジ日時 2023-09-14 22:51:56
合計ジャッジ時間 4,821 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
6,804 KB
testcase_01 AC 16 ms
7,268 KB
testcase_02 AC 37 ms
7,592 KB
testcase_03 AC 29 ms
7,688 KB
testcase_04 AC 16 ms
6,784 KB
testcase_05 AC 42 ms
8,076 KB
testcase_06 AC 15 ms
6,672 KB
testcase_07 AC 12 ms
6,892 KB
testcase_08 AC 9 ms
6,260 KB
testcase_09 AC 30 ms
6,992 KB
testcase_10 AC 45 ms
7,972 KB
testcase_11 AC 44 ms
8,332 KB
testcase_12 AC 29 ms
7,056 KB
testcase_13 AC 19 ms
6,528 KB
testcase_14 AC 20 ms
7,184 KB
testcase_15 AC 47 ms
8,576 KB
testcase_16 AC 46 ms
8,600 KB
testcase_17 AC 46 ms
8,560 KB
testcase_18 AC 46 ms
8,548 KB
testcase_19 AC 46 ms
8,516 KB
testcase_20 AC 47 ms
8,512 KB
testcase_21 AC 46 ms
8,820 KB
testcase_22 AC 46 ms
8,620 KB
testcase_23 AC 5 ms
5,852 KB
testcase_24 AC 6 ms
6,052 KB
testcase_25 AC 5 ms
5,844 KB
testcase_26 AC 5 ms
5,872 KB
testcase_27 AC 5 ms
5,892 KB
testcase_28 AC 4 ms
5,844 KB
testcase_29 AC 6 ms
6,140 KB
testcase_30 AC 6 ms
6,044 KB
testcase_31 AC 5 ms
5,900 KB
testcase_32 AC 4 ms
5,944 KB
testcase_33 AC 6 ms
5,944 KB
testcase_34 AC 5 ms
6,112 KB
testcase_35 AC 7 ms
5,980 KB
testcase_36 AC 5 ms
6,056 KB
testcase_37 AC 8 ms
6,164 KB
testcase_38 AC 14 ms
6,472 KB
testcase_39 AC 27 ms
7,484 KB
testcase_40 AC 11 ms
6,684 KB
testcase_41 AC 3 ms
5,736 KB
testcase_42 AC 4 ms
5,748 KB
testcase_43 AC 3 ms
5,780 KB
testcase_44 AC 3 ms
5,892 KB
testcase_45 AC 3 ms
5,748 KB
testcase_46 AC 4 ms
5,800 KB
testcase_47 AC 3 ms
5,744 KB
testcase_48 AC 4 ms
5,752 KB
testcase_49 AC 4 ms
6,052 KB
testcase_50 AC 3 ms
5,748 KB
testcase_51 AC 3 ms
5,748 KB
testcase_52 AC 3 ms
5,792 KB
testcase_53 AC 3 ms
5,744 KB
testcase_54 AC 3 ms
5,992 KB
testcase_55 AC 3 ms
5,916 KB
testcase_56 AC 3 ms
5,744 KB
testcase_57 AC 3 ms
5,740 KB
testcase_58 AC 3 ms
5,748 KB
testcase_59 AC 3 ms
5,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,A;
vector<pair<int,int>> C[101010];

ll dp[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>A;
	FOR(i,M) {
		cin>>x>>y>>r;
		C[y].push_back({x-1,r});
	}
	
	ll ma=0;
	for(i=1;i<=N;i++) {
		dp[i]=ma-A;
		FORR(c,C[i]) dp[i]=max(dp[i],dp[c.first]+c.second-A);
		
		ma=max(ma,dp[i]);
	}
	cout<<dp[N]+A<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0