結果

問題 No.844 split game
ユーザー furafura
提出日時 2020-06-01 14:17:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,316 bytes
コンパイル時間 4,163 ms
コンパイル使用メモリ 214,916 KB
実行使用メモリ 6,756 KB
最終ジャッジ日時 2024-05-01 13:08:33
合計ジャッジ時間 7,173 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
5,248 KB
testcase_01 AC 26 ms
5,376 KB
testcase_02 AC 76 ms
5,776 KB
testcase_03 AC 53 ms
5,808 KB
testcase_04 AC 27 ms
5,376 KB
testcase_05 AC 78 ms
6,396 KB
testcase_06 AC 24 ms
5,376 KB
testcase_07 AC 18 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 60 ms
5,376 KB
testcase_10 AC 84 ms
6,476 KB
testcase_11 AC 79 ms
6,656 KB
testcase_12 AC 59 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 35 ms
5,376 KB
testcase_15 AC 87 ms
6,756 KB
testcase_16 AC 86 ms
6,632 KB
testcase_17 AC 88 ms
6,628 KB
testcase_18 AC 86 ms
6,680 KB
testcase_19 AC 87 ms
6,756 KB
testcase_20 WA -
testcase_21 AC 87 ms
6,624 KB
testcase_22 AC 87 ms
6,752 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 8 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 7 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 7 ms
5,376 KB
testcase_30 AC 8 ms
5,376 KB
testcase_31 AC 6 ms
5,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 10 ms
5,376 KB
testcase_36 AC 6 ms
5,376 KB
testcase_37 AC 14 ms
5,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 WA -
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 1 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 WA -
testcase_55 AC 2 ms
5,376 KB
testcase_56 WA -
testcase_57 AC 1 ms
5,376 KB
testcase_58 AC 2 ms
5,376 KB
testcase_59 AC 2 ms
5,376 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;
	interval(){}
	interval(const T& l,const T& r,int wt):l(l),r(r),wt(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++;

	vector<int> X={0,1,L+1};
	rep(i,m){
		X.emplace_back(I[i].l);
		X.emplace_back(I[i].r);
	}
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());

	rep(i,m){
		I[i].l=lower_bound(X.begin(),X.end(),I[i].l)-X.begin();
		I[i].r=lower_bound(X.begin(),X.end(),I[i].r)-X.begin();
	}

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

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

	return 0;
}
0