結果

問題 No.844 split game
ユーザー okok
提出日時 2019-06-28 23:09:55
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,623 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 76,972 KB
実行使用メモリ 6,204 KB
最終ジャッジ日時 2023-09-14 22:37:28
合計ジャッジ時間 7,484 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX 11000

vector<pair<int,int>> num[MAX];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M, A;
	int l, r, p;
	static int dp[MAX][3];
	cin>>N>>M>>A;
	

	
	for(int i = 0; i < M; i++){
		cin>>l>>r>>p;
		num[r].push_back(make_pair(l-1, p));
	}
	
	for(int i = 1; i <= N; i++){
		if(N == i){
			int max_ = -INF;
			max_ = max(max_, dp[i-1][1]);
			max_ = max(max_, dp[i-1][0]);
			dp[i][0] = max(0ll,max(dp[i-1][1], dp[i-1][0]));
			for(int j = 0; j < num[i].size(); j++){
				max_ = max(dp[num[i][j].first][0] - A + num[i][j].second, max_);
				max_ = max(dp[num[i][j].first][1] + num[i][j].second, max_);
				// cout<<num[i][j].first<<" "<<num[i][j].second<<endl;
			}
			dp[i][1] = max_;
		} else {
			int max_ = -INF, max2 = 0;
			max_ = max(max_, dp[i-1][1] - A);
			max_ = max(max_, dp[i-1][0] - A);
			dp[i][0] = max(0ll,max(dp[i-1][1], dp[i-1][0]));
			for(int j = 0; j < num[i].size(); j++){
				max_ = max(dp[num[i][j].first][0] - A*2 + num[i][j].second, max_);
				max_ = max(dp[num[i][j].first][1] - A + num[i][j].second, max_);
			}
			dp[i][1] = max_;
		}
		// cout<<"i = "<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<endl;
	}
	
	cout<<max(dp[N][0], dp[N][1])<<endl;
	
	return 0;
}
0