結果

問題 No.844 split game
ユーザー ahe100ahe100
提出日時 2019-06-28 22:29:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 920 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 168,796 KB
実行使用メモリ 9,940 KB
最終ジャッジ日時 2023-09-14 22:18:21
合計ジャッジ時間 6,363 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
7,464 KB
testcase_01 AC 34 ms
8,000 KB
testcase_02 AC 90 ms
8,740 KB
testcase_03 AC 65 ms
8,660 KB
testcase_04 AC 34 ms
7,068 KB
testcase_05 AC 103 ms
9,236 KB
testcase_06 AC 32 ms
7,100 KB
testcase_07 AC 26 ms
7,460 KB
testcase_08 AC 18 ms
6,460 KB
testcase_09 AC 77 ms
7,848 KB
testcase_10 AC 109 ms
9,228 KB
testcase_11 AC 104 ms
9,640 KB
testcase_12 AC 73 ms
7,768 KB
testcase_13 AC 46 ms
7,044 KB
testcase_14 AC 46 ms
7,740 KB
testcase_15 AC 114 ms
9,892 KB
testcase_16 AC 114 ms
9,876 KB
testcase_17 AC 114 ms
9,940 KB
testcase_18 AC 113 ms
9,880 KB
testcase_19 AC 114 ms
9,848 KB
testcase_20 AC 114 ms
9,840 KB
testcase_21 AC 114 ms
9,872 KB
testcase_22 AC 113 ms
9,872 KB
testcase_23 AC 6 ms
5,856 KB
testcase_24 AC 10 ms
6,072 KB
testcase_25 AC 7 ms
5,884 KB
testcase_26 AC 5 ms
5,796 KB
testcase_27 AC 9 ms
6,020 KB
testcase_28 AC 5 ms
5,816 KB
testcase_29 AC 9 ms
6,080 KB
testcase_30 AC 11 ms
6,024 KB
testcase_31 AC 9 ms
5,988 KB
testcase_32 AC 5 ms
5,832 KB
testcase_33 AC 11 ms
6,040 KB
testcase_34 AC 8 ms
5,928 KB
testcase_35 AC 13 ms
6,028 KB
testcase_36 AC 9 ms
5,956 KB
testcase_37 AC 18 ms
6,132 KB
testcase_38 AC 32 ms
6,880 KB
testcase_39 AC 63 ms
7,904 KB
testcase_40 AC 21 ms
7,200 KB
testcase_41 AC 3 ms
5,748 KB
testcase_42 AC 3 ms
5,664 KB
testcase_43 AC 3 ms
5,756 KB
testcase_44 AC 4 ms
5,768 KB
testcase_45 AC 3 ms
5,704 KB
testcase_46 AC 3 ms
5,664 KB
testcase_47 AC 4 ms
5,780 KB
testcase_48 AC 4 ms
5,908 KB
testcase_49 AC 4 ms
5,904 KB
testcase_50 AC 4 ms
5,908 KB
testcase_51 AC 3 ms
5,760 KB
testcase_52 AC 3 ms
5,748 KB
testcase_53 AC 4 ms
5,684 KB
testcase_54 AC 3 ms
5,700 KB
testcase_55 AC 3 ms
5,712 KB
testcase_56 AC 3 ms
5,792 KB
testcase_57 AC 4 ms
5,764 KB
testcase_58 AC 3 ms
5,688 KB
testcase_59 AC 4 ms
5,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
dp(i,0 or 1) = iまでで、(iを引いた)時の最大得点
*/

struct D{ll r,p;};

ll n,m,a,dp[100010][2];
vector<D> v[100010];

void init(){
	cin>>n>>m>>a;
	rep(i,m){
		ll l,r,p;
		cin>>l>>r>>p;
		v[l-1].push_back({r,p});
	}
	rep(i,n+1)rep(j,2)dp[i][j]=-1e18;
	dp[0][1]=0;
}

int main(void){
	init();
	reg(i,0,n){
		if(i>0)dp[i][0]=max({dp[i][0],dp[i-1][1],dp[i-1][0]});
		dp[i][1]=max(dp[i][1],dp[i][0]-a);
		for(D p:v[i]){
			// iに引いたらrに引いて、その間には引かない。
			dp[p.r][1]=max({dp[p.r][1], dp[i][1]+p.p-a, dp[i][0]+p.p-2*a});
		}
	}
	cout<<max(dp[n][0],dp[n][1]+a)<<endl;
	return 0;
}
0