結果

問題 No.844 split game
ユーザー leaf_1415leaf_1415
提出日時 2019-07-01 22:15:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 62,876 KB
実行使用メモリ 9,404 KB
最終ジャッジ日時 2023-09-25 09:21:49
合計ジャッジ時間 7,145 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
7,064 KB
testcase_01 AC 32 ms
7,300 KB
testcase_02 AC 88 ms
8,444 KB
testcase_03 AC 62 ms
8,032 KB
testcase_04 AC 33 ms
6,868 KB
testcase_05 AC 100 ms
8,668 KB
testcase_06 AC 31 ms
6,768 KB
testcase_07 AC 25 ms
6,936 KB
testcase_08 AC 17 ms
6,572 KB
testcase_09 AC 75 ms
7,800 KB
testcase_10 AC 108 ms
9,016 KB
testcase_11 AC 101 ms
8,888 KB
testcase_12 AC 73 ms
8,020 KB
testcase_13 AC 46 ms
6,956 KB
testcase_14 AC 45 ms
7,264 KB
testcase_15 AC 111 ms
9,404 KB
testcase_16 AC 111 ms
9,204 KB
testcase_17 AC 113 ms
9,396 KB
testcase_18 AC 112 ms
9,080 KB
testcase_19 AC 111 ms
9,116 KB
testcase_20 AC 112 ms
9,304 KB
testcase_21 AC 111 ms
9,084 KB
testcase_22 AC 111 ms
9,264 KB
testcase_23 AC 6 ms
5,824 KB
testcase_24 AC 10 ms
5,996 KB
testcase_25 AC 7 ms
5,836 KB
testcase_26 AC 5 ms
5,800 KB
testcase_27 AC 9 ms
5,944 KB
testcase_28 AC 4 ms
5,776 KB
testcase_29 AC 8 ms
6,132 KB
testcase_30 AC 10 ms
5,964 KB
testcase_31 AC 9 ms
6,004 KB
testcase_32 AC 4 ms
5,780 KB
testcase_33 AC 11 ms
6,044 KB
testcase_34 AC 8 ms
5,976 KB
testcase_35 AC 13 ms
6,132 KB
testcase_36 AC 9 ms
5,984 KB
testcase_37 AC 18 ms
6,628 KB
testcase_38 AC 32 ms
7,048 KB
testcase_39 AC 65 ms
8,248 KB
testcase_40 AC 21 ms
6,756 KB
testcase_41 AC 3 ms
5,752 KB
testcase_42 AC 3 ms
5,752 KB
testcase_43 AC 4 ms
5,816 KB
testcase_44 AC 4 ms
5,812 KB
testcase_45 AC 3 ms
5,724 KB
testcase_46 AC 3 ms
5,704 KB
testcase_47 AC 3 ms
5,876 KB
testcase_48 AC 3 ms
5,748 KB
testcase_49 AC 4 ms
5,744 KB
testcase_50 AC 4 ms
5,872 KB
testcase_51 AC 3 ms
5,680 KB
testcase_52 AC 3 ms
5,880 KB
testcase_53 AC 4 ms
5,708 KB
testcase_54 AC 4 ms
5,812 KB
testcase_55 AC 3 ms
5,716 KB
testcase_56 AC 4 ms
5,696 KB
testcase_57 AC 4 ms
5,708 KB
testcase_58 AC 4 ms
5,704 KB
testcase_59 AC 4 ms
5,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, m, a;
vector<P> vec[100005];
llint dp[100005];

int main(void)
{
	cin >> n >> m >> a;
	llint l, r, p;
	for(int i = 1; i <= m; i++){
		cin >> l >> r >> p;
		l--;
		vec[r].push_back(make_pair(l, p));
	}
	
	llint mx = 0;
	for(int i = 1; i <= n; i++) dp[i] = -inf;
	dp[0] = 0;
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < vec[i].size(); j++){
			dp[i] = max(dp[i], dp[vec[i][j].first] + vec[i][j].second - a);
		}
		dp[i] = max(dp[i], mx - a);
		mx = max(mx, dp[i]);
	}
	cout << dp[n] + a << endl;
	
	return 0;
}
0