結果

問題 No.844 split game
ユーザー kotatsugamekotatsugame
提出日時 2019-07-04 00:02:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 2,172 ms
コンパイル使用メモリ 73,340 KB
実行使用メモリ 10,340 KB
最終ジャッジ日時 2023-10-17 10:34:42
合計ジャッジ時間 7,890 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
8,412 KB
testcase_01 AC 33 ms
8,588 KB
testcase_02 AC 89 ms
9,736 KB
testcase_03 AC 64 ms
9,340 KB
testcase_04 AC 34 ms
8,176 KB
testcase_05 AC 101 ms
10,016 KB
testcase_06 AC 32 ms
8,072 KB
testcase_07 AC 26 ms
8,244 KB
testcase_08 AC 17 ms
7,612 KB
testcase_09 AC 78 ms
9,100 KB
testcase_10 AC 108 ms
10,084 KB
testcase_11 AC 103 ms
10,112 KB
testcase_12 AC 76 ms
9,084 KB
testcase_13 AC 47 ms
8,308 KB
testcase_14 AC 46 ms
8,616 KB
testcase_15 AC 113 ms
10,336 KB
testcase_16 AC 112 ms
10,332 KB
testcase_17 AC 112 ms
10,336 KB
testcase_18 AC 112 ms
10,336 KB
testcase_19 AC 112 ms
10,336 KB
testcase_20 AC 113 ms
10,336 KB
testcase_21 AC 112 ms
10,340 KB
testcase_22 AC 112 ms
10,340 KB
testcase_23 AC 6 ms
7,176 KB
testcase_24 AC 10 ms
7,340 KB
testcase_25 AC 7 ms
7,208 KB
testcase_26 AC 5 ms
7,148 KB
testcase_27 AC 9 ms
7,264 KB
testcase_28 AC 4 ms
7,144 KB
testcase_29 AC 9 ms
7,308 KB
testcase_30 AC 10 ms
7,340 KB
testcase_31 AC 9 ms
7,268 KB
testcase_32 AC 4 ms
7,136 KB
testcase_33 AC 12 ms
7,408 KB
testcase_34 AC 8 ms
7,260 KB
testcase_35 AC 14 ms
7,416 KB
testcase_36 AC 9 ms
7,292 KB
testcase_37 AC 19 ms
7,440 KB
testcase_38 AC 33 ms
8,080 KB
testcase_39 AC 66 ms
9,160 KB
testcase_40 AC 21 ms
8,076 KB
testcase_41 AC 3 ms
7,052 KB
testcase_42 AC 3 ms
7,052 KB
testcase_43 AC 3 ms
7,052 KB
testcase_44 AC 4 ms
7,056 KB
testcase_45 AC 4 ms
7,052 KB
testcase_46 AC 3 ms
7,052 KB
testcase_47 AC 3 ms
7,052 KB
testcase_48 AC 3 ms
7,052 KB
testcase_49 AC 3 ms
7,052 KB
testcase_50 AC 3 ms
7,052 KB
testcase_51 AC 3 ms
7,052 KB
testcase_52 AC 3 ms
7,052 KB
testcase_53 AC 3 ms
7,052 KB
testcase_54 AC 4 ms
7,052 KB
testcase_55 AC 4 ms
7,056 KB
testcase_56 AC 3 ms
7,056 KB
testcase_57 AC 3 ms
7,056 KB
testcase_58 AC 3 ms
7,056 KB
testcase_59 AC 3 ms
7,056 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,M;
long A;
vector<pair<int,long> >G[1<<17];
long dp[1<<17];
main()
{
	cin>>N>>M>>A;
	for(int i=0;i<M;i++)
	{
		long l,r,p;cin>>l>>r>>p;
		G[l-1].push_back({r,p});
	}
	for(int i=1;i<N;i++)dp[i]=-1e18;
	long ans=0;
	for(int i=0;i<N;i++)
	{
		ans=max(ans,dp[i]);
		if(i)dp[i]=max(dp[i],ans-A);
		for(pair<int,long>p:G[i])
		{
			dp[p.first]=max(dp[p.first],dp[i]+p.second-(p.first==N?0:A));
		}
	}
	cout<<max(ans,dp[N])<<endl;
}
0