結果

問題 No.844 split game
ユーザー pockynypockyny
提出日時 2019-06-28 22:09:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 85,128 KB
実行使用メモリ 9,388 KB
最終ジャッジ日時 2023-09-14 22:05:07
合計ジャッジ時間 6,199 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
7,088 KB
testcase_01 AC 34 ms
7,288 KB
testcase_02 AC 92 ms
8,668 KB
testcase_03 AC 67 ms
8,284 KB
testcase_04 AC 34 ms
6,988 KB
testcase_05 AC 104 ms
8,660 KB
testcase_06 AC 33 ms
6,708 KB
testcase_07 AC 26 ms
6,960 KB
testcase_08 AC 17 ms
6,256 KB
testcase_09 AC 76 ms
7,856 KB
testcase_10 AC 109 ms
8,824 KB
testcase_11 AC 103 ms
8,896 KB
testcase_12 AC 74 ms
7,776 KB
testcase_13 AC 47 ms
6,972 KB
testcase_14 AC 46 ms
7,268 KB
testcase_15 AC 114 ms
9,388 KB
testcase_16 AC 112 ms
9,088 KB
testcase_17 AC 113 ms
9,160 KB
testcase_18 AC 114 ms
9,228 KB
testcase_19 AC 113 ms
9,148 KB
testcase_20 AC 113 ms
9,148 KB
testcase_21 AC 113 ms
9,100 KB
testcase_22 AC 116 ms
9,128 KB
testcase_23 AC 6 ms
6,084 KB
testcase_24 AC 10 ms
6,036 KB
testcase_25 AC 8 ms
5,852 KB
testcase_26 AC 6 ms
5,864 KB
testcase_27 AC 9 ms
5,912 KB
testcase_28 AC 4 ms
5,784 KB
testcase_29 AC 9 ms
6,004 KB
testcase_30 AC 10 ms
6,300 KB
testcase_31 AC 10 ms
5,932 KB
testcase_32 AC 4 ms
5,832 KB
testcase_33 AC 11 ms
6,352 KB
testcase_34 AC 8 ms
5,972 KB
testcase_35 AC 13 ms
6,184 KB
testcase_36 AC 9 ms
5,972 KB
testcase_37 AC 19 ms
6,304 KB
testcase_38 AC 33 ms
7,016 KB
testcase_39 AC 67 ms
8,304 KB
testcase_40 AC 23 ms
6,712 KB
testcase_41 AC 3 ms
5,772 KB
testcase_42 AC 4 ms
5,812 KB
testcase_43 AC 3 ms
5,740 KB
testcase_44 AC 3 ms
5,792 KB
testcase_45 AC 4 ms
5,748 KB
testcase_46 AC 4 ms
5,852 KB
testcase_47 AC 4 ms
5,684 KB
testcase_48 AC 4 ms
5,744 KB
testcase_49 AC 4 ms
5,752 KB
testcase_50 AC 4 ms
5,824 KB
testcase_51 AC 4 ms
5,744 KB
testcase_52 AC 4 ms
5,868 KB
testcase_53 AC 3 ms
5,796 KB
testcase_54 AC 3 ms
5,788 KB
testcase_55 AC 4 ms
5,812 KB
testcase_56 AC 4 ms
5,744 KB
testcase_57 AC 4 ms
5,784 KB
testcase_58 AC 4 ms
5,748 KB
testcase_59 AC 4 ms
5,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
vector<pair<ll,ll>> v[100010];
set<ll> s;
ll dp[100010],b[100010];
int main(){
	ll i,j,n,m,a;
	cin >> n >> m >> a;
	for(i=0;i<m;i++){
		ll l,r,p;
		cin >> l >> r >> p; l--;
		v[r].push_back({l,p});
		if(r==n){
			s.insert(l);
			b[l] = p;
		}
	}
	for(i=1;i<=n;i++){
		dp[i] = -a;
	}
	dp[0] = 0;
	ll mx = 0;
	for(i=1;i<n;i++){
		dp[i] = mx - a;
		for(j=0;j<v[i].size();j++){
			dp[i] = max(dp[i],dp[v[i][j].first] + v[i][j].second - a);
		}
		mx = max(mx,dp[i]);
	}
	ll ans = -100000000000000;
	for(i=0;i<n;i++){
		if(s.count(i)){
			dp[i] += b[i];
		}
		ans = max(ans,dp[i]);
	}
	cout << ans << endl;
}
		
0