結果

問題 No.844 split game
ユーザー kotatsugamekotatsugame
提出日時 2019-06-28 23:29:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 72,512 KB
実行使用メモリ 10,108 KB
最終ジャッジ日時 2023-09-14 22:44:24
合計ジャッジ時間 5,052 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
7,884 KB
testcase_01 AC 32 ms
8,084 KB
testcase_02 AC 87 ms
9,100 KB
testcase_03 AC 63 ms
8,864 KB
testcase_04 AC 32 ms
7,632 KB
testcase_05 AC 99 ms
9,392 KB
testcase_06 AC 31 ms
7,436 KB
testcase_07 AC 25 ms
7,764 KB
testcase_08 AC 17 ms
6,988 KB
testcase_09 AC 75 ms
8,556 KB
testcase_10 AC 105 ms
9,468 KB
testcase_11 AC 100 ms
9,560 KB
testcase_12 AC 72 ms
8,496 KB
testcase_13 AC 45 ms
7,648 KB
testcase_14 AC 44 ms
7,976 KB
testcase_15 AC 109 ms
10,108 KB
testcase_16 AC 109 ms
9,852 KB
testcase_17 AC 109 ms
9,812 KB
testcase_18 AC 110 ms
9,924 KB
testcase_19 AC 111 ms
9,820 KB
testcase_20 AC 110 ms
9,816 KB
testcase_21 AC 110 ms
9,868 KB
testcase_22 AC 108 ms
9,916 KB
testcase_23 AC 6 ms
6,588 KB
testcase_24 AC 10 ms
6,756 KB
testcase_25 AC 7 ms
6,752 KB
testcase_26 AC 5 ms
6,516 KB
testcase_27 AC 8 ms
6,632 KB
testcase_28 AC 4 ms
6,484 KB
testcase_29 AC 8 ms
6,668 KB
testcase_30 AC 10 ms
6,700 KB
testcase_31 AC 9 ms
6,792 KB
testcase_32 AC 4 ms
6,552 KB
testcase_33 AC 11 ms
6,872 KB
testcase_34 AC 8 ms
6,640 KB
testcase_35 AC 13 ms
6,756 KB
testcase_36 AC 9 ms
6,772 KB
testcase_37 AC 18 ms
6,792 KB
testcase_38 AC 31 ms
7,440 KB
testcase_39 AC 62 ms
8,540 KB
testcase_40 AC 21 ms
7,480 KB
testcase_41 AC 4 ms
6,420 KB
testcase_42 AC 3 ms
6,388 KB
testcase_43 AC 3 ms
6,488 KB
testcase_44 AC 3 ms
6,692 KB
testcase_45 AC 3 ms
6,412 KB
testcase_46 AC 3 ms
6,532 KB
testcase_47 AC 3 ms
6,464 KB
testcase_48 AC 3 ms
6,464 KB
testcase_49 AC 4 ms
6,428 KB
testcase_50 AC 3 ms
6,432 KB
testcase_51 AC 3 ms
6,420 KB
testcase_52 AC 3 ms
6,596 KB
testcase_53 AC 3 ms
6,532 KB
testcase_54 AC 3 ms
6,420 KB
testcase_55 AC 3 ms
6,532 KB
testcase_56 AC 3 ms
6,536 KB
testcase_57 AC 3 ms
6,396 KB
testcase_58 AC 3 ms
6,468 KB
testcase_59 AC 4 ms
6,420 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-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