結果

問題 No.844 split game
ユーザー pockynypockyny
提出日時 2019-06-28 22:07:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 649 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 84,288 KB
実行使用メモリ 9,408 KB
最終ジャッジ日時 2023-09-14 22:02:04
合計ジャッジ時間 5,470 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
7,112 KB
testcase_01 AC 33 ms
7,292 KB
testcase_02 AC 90 ms
8,424 KB
testcase_03 AC 65 ms
8,052 KB
testcase_04 AC 34 ms
7,032 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 112 ms
9,104 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 113 ms
9,128 KB
testcase_19 AC 112 ms
9,168 KB
testcase_20 AC 113 ms
9,156 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 5 ms
5,812 KB
testcase_27 WA -
testcase_28 AC 4 ms
5,796 KB
testcase_29 AC 9 ms
5,952 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 4 ms
5,776 KB
testcase_33 AC 11 ms
6,064 KB
testcase_34 AC 8 ms
5,964 KB
testcase_35 AC 13 ms
6,124 KB
testcase_36 AC 9 ms
5,948 KB
testcase_37 AC 18 ms
6,304 KB
testcase_38 AC 32 ms
7,024 KB
testcase_39 AC 68 ms
8,248 KB
testcase_40 AC 22 ms
6,796 KB
testcase_41 AC 3 ms
5,760 KB
testcase_42 AC 3 ms
5,696 KB
testcase_43 AC 3 ms
5,768 KB
testcase_44 AC 4 ms
5,700 KB
testcase_45 AC 3 ms
5,696 KB
testcase_46 AC 3 ms
5,816 KB
testcase_47 AC 3 ms
5,760 KB
testcase_48 WA -
testcase_49 AC 4 ms
5,704 KB
testcase_50 AC 3 ms
5,696 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 3 ms
5,808 KB
testcase_54 AC 4 ms
5,772 KB
testcase_55 AC 4 ms
5,720 KB
testcase_56 AC 3 ms
5,700 KB
testcase_57 AC 3 ms
5,812 KB
testcase_58 AC 4 ms
5,708 KB
testcase_59 AC 3 ms
5,712 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;
	for(i=1;i<n;i++){
		for(j=0;j<v[i].size();j++){
			dp[i] = max(dp[i],dp[v[i][j].first] + v[i][j].second - a);
		}
	}
	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