結果

問題 No.844 split game
ユーザー tempura_pptempura_pp
提出日時 2019-03-14 00:10:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 169,136 KB
実行使用メモリ 10,044 KB
最終ジャッジ日時 2023-09-06 20:44:19
合計ジャッジ時間 5,925 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
6,024 KB
testcase_01 AC 33 ms
7,788 KB
testcase_02 AC 84 ms
7,308 KB
testcase_03 AC 62 ms
8,344 KB
testcase_04 AC 32 ms
5,488 KB
testcase_05 AC 96 ms
8,756 KB
testcase_06 AC 30 ms
5,448 KB
testcase_07 AC 25 ms
6,964 KB
testcase_08 AC 15 ms
4,688 KB
testcase_09 AC 72 ms
5,980 KB
testcase_10 AC 104 ms
8,368 KB
testcase_11 AC 97 ms
9,528 KB
testcase_12 AC 69 ms
5,768 KB
testcase_13 AC 42 ms
4,920 KB
testcase_14 AC 43 ms
6,832 KB
testcase_15 AC 108 ms
9,856 KB
testcase_16 AC 110 ms
9,824 KB
testcase_17 AC 110 ms
9,956 KB
testcase_18 AC 108 ms
9,960 KB
testcase_19 AC 108 ms
9,812 KB
testcase_20 AC 107 ms
9,864 KB
testcase_21 AC 109 ms
9,836 KB
testcase_22 AC 107 ms
10,044 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 8 ms
4,376 KB
testcase_25 AC 5 ms
4,376 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 7 ms
4,380 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 7 ms
4,380 KB
testcase_30 AC 8 ms
4,380 KB
testcase_31 AC 7 ms
4,376 KB
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 10 ms
4,376 KB
testcase_34 AC 6 ms
4,376 KB
testcase_35 AC 11 ms
4,380 KB
testcase_36 AC 7 ms
4,380 KB
testcase_37 AC 16 ms
4,376 KB
testcase_38 AC 30 ms
4,912 KB
testcase_39 AC 64 ms
6,416 KB
testcase_40 AC 20 ms
5,992 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2 ms
4,376 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
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(){
	int 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;
		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;
}
0