結果

問題 No.844 split game
ユーザー furafura
提出日時 2020-06-01 14:27:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 209,804 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 13:22:15
合計ジャッジ時間 4,495 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
6,812 KB
testcase_01 AC 13 ms
6,940 KB
testcase_02 AC 35 ms
6,940 KB
testcase_03 AC 25 ms
6,940 KB
testcase_04 AC 14 ms
6,944 KB
testcase_05 AC 37 ms
6,944 KB
testcase_06 AC 12 ms
6,940 KB
testcase_07 AC 10 ms
6,944 KB
testcase_08 AC 7 ms
6,940 KB
testcase_09 AC 30 ms
6,940 KB
testcase_10 AC 40 ms
6,940 KB
testcase_11 AC 40 ms
6,944 KB
testcase_12 AC 30 ms
6,940 KB
testcase_13 AC 18 ms
6,940 KB
testcase_14 AC 17 ms
6,944 KB
testcase_15 AC 41 ms
6,944 KB
testcase_16 AC 41 ms
6,940 KB
testcase_17 AC 40 ms
6,940 KB
testcase_18 AC 40 ms
6,940 KB
testcase_19 AC 42 ms
6,944 KB
testcase_20 AC 42 ms
6,944 KB
testcase_21 AC 41 ms
6,940 KB
testcase_22 AC 42 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 4 ms
6,944 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 4 ms
6,944 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 4 ms
6,940 KB
testcase_30 AC 4 ms
6,944 KB
testcase_31 AC 4 ms
6,944 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 6 ms
6,940 KB
testcase_34 AC 4 ms
6,944 KB
testcase_35 AC 6 ms
6,940 KB
testcase_36 AC 4 ms
6,944 KB
testcase_37 AC 8 ms
6,944 KB
testcase_38 AC 14 ms
6,944 KB
testcase_39 AC 30 ms
6,944 KB
testcase_40 AC 9 ms
6,944 KB
testcase_41 AC 1 ms
6,944 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 2 ms
6,940 KB
testcase_44 AC 2 ms
6,944 KB
testcase_45 AC 2 ms
6,944 KB
testcase_46 AC 1 ms
6,944 KB
testcase_47 AC 1 ms
6,940 KB
testcase_48 AC 2 ms
6,944 KB
testcase_49 AC 1 ms
6,940 KB
testcase_50 AC 1 ms
6,940 KB
testcase_51 AC 1 ms
6,940 KB
testcase_52 AC 1 ms
6,940 KB
testcase_53 AC 1 ms
6,944 KB
testcase_54 AC 2 ms
6,944 KB
testcase_55 AC 2 ms
6,940 KB
testcase_56 AC 2 ms
6,940 KB
testcase_57 AC 1 ms
6,940 KB
testcase_58 AC 1 ms
6,944 KB
testcase_59 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

template<class T> struct interval{
	T l,r;
	int wt;
	bool operator<(const interval& I)const{ return make_tuple(r,l)<make_tuple(I.r,I.l); }
};

const long long INF=1LL<<61;

int main(){
	int L,m,c; scanf("%d%d%d",&L,&m,&c);
	vector<interval<int>> I(m);
	rep(i,m) scanf("%d%d%d",&I[i].l,&I[i].r,&I[i].wt), I[i].r++;

	sort(I.begin(),I.end());

	int idx=0;
	// dp[x] = ([1, x) に含まれる区間だけを考えて, x の左に区切りを入れたときのスコアの最大値)
	vector<lint> dp(L+2,-INF),dp_max(L+2,-INF);
	dp[1]=0;
	dp_max[1]=0;
	for(int x=2;x<=L+1;x++){
		while(idx<m && I[idx].r==x){
			dp[x]=max(dp[x],dp[I[idx].l]+I[idx].wt-(x<L+1?c:0));
			dp[x]=max(dp[x],dp_max[I[idx].l-1]+I[idx].wt-(x<L+1?2*c:c));
			idx++;
		}
		dp_max[x]=max(dp_max[x-1],dp[x]);
	}
	printf("%lld\n",dp_max[L+1]);

	return 0;
}
0