結果

問題 No.844 split game
ユーザー matsukin11111matsukin11111
提出日時 2019-06-30 22:41:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 1,791 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 88,864 KB
実行使用メモリ 12,300 KB
最終ジャッジ日時 2023-09-21 08:59:02
合計ジャッジ時間 8,688 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
10,572 KB
testcase_01 AC 54 ms
10,416 KB
testcase_02 AC 142 ms
11,920 KB
testcase_03 AC 102 ms
11,160 KB
testcase_04 AC 56 ms
10,392 KB
testcase_05 AC 162 ms
11,840 KB
testcase_06 AC 49 ms
10,224 KB
testcase_07 AC 39 ms
10,264 KB
testcase_08 AC 25 ms
9,924 KB
testcase_09 AC 119 ms
11,696 KB
testcase_10 AC 171 ms
12,016 KB
testcase_11 AC 164 ms
12,084 KB
testcase_12 AC 116 ms
11,440 KB
testcase_13 AC 73 ms
10,644 KB
testcase_14 AC 72 ms
10,792 KB
testcase_15 AC 179 ms
12,164 KB
testcase_16 AC 179 ms
12,168 KB
testcase_17 AC 175 ms
12,104 KB
testcase_18 AC 177 ms
12,164 KB
testcase_19 AC 177 ms
12,300 KB
testcase_20 AC 180 ms
12,292 KB
testcase_21 AC 181 ms
12,108 KB
testcase_22 AC 180 ms
12,104 KB
testcase_23 AC 9 ms
9,616 KB
testcase_24 AC 16 ms
9,692 KB
testcase_25 AC 11 ms
9,636 KB
testcase_26 AC 7 ms
9,588 KB
testcase_27 AC 13 ms
9,800 KB
testcase_28 AC 6 ms
9,656 KB
testcase_29 AC 13 ms
9,712 KB
testcase_30 AC 16 ms
9,828 KB
testcase_31 AC 13 ms
9,664 KB
testcase_32 AC 5 ms
9,564 KB
testcase_33 AC 18 ms
10,108 KB
testcase_34 AC 12 ms
9,744 KB
testcase_35 AC 20 ms
9,988 KB
testcase_36 AC 14 ms
9,720 KB
testcase_37 AC 29 ms
10,180 KB
testcase_38 AC 56 ms
10,648 KB
testcase_39 AC 118 ms
11,916 KB
testcase_40 AC 37 ms
10,092 KB
testcase_41 AC 3 ms
9,612 KB
testcase_42 AC 4 ms
9,492 KB
testcase_43 AC 3 ms
9,492 KB
testcase_44 AC 3 ms
9,488 KB
testcase_45 AC 4 ms
9,488 KB
testcase_46 AC 3 ms
9,680 KB
testcase_47 AC 4 ms
9,532 KB
testcase_48 AC 3 ms
9,552 KB
testcase_49 AC 3 ms
9,488 KB
testcase_50 AC 4 ms
9,552 KB
testcase_51 AC 3 ms
9,488 KB
testcase_52 AC 3 ms
9,488 KB
testcase_53 AC 3 ms
9,504 KB
testcase_54 AC 3 ms
9,608 KB
testcase_55 AC 3 ms
9,480 KB
testcase_56 AC 4 ms
9,616 KB
testcase_57 AC 4 ms
9,564 KB
testcase_58 AC 3 ms
9,692 KB
testcase_59 AC 4 ms
9,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

//segtree
const ll N = 1 << 18;
ll seg[2 * N];
void st(ll p, ll v) {
	p += N - 1;
	seg[p] = v;
	while (p>0) {
		p = (p - 1) / 2;
		seg[p] = max(seg[2 * p + 1], seg[2 * p + 2]);
	}
}
ll query(ll l, ll r, ll a, ll b, ll k) {
	if (r <= a || b <= l)return -inf;
	if (l <= a && b <= r)return seg[k];
	int m = (a + b) / 2;
	return max(query(l, r, a, m, 2 * k + 1), query(l, r, m, b, 2 * k + 2));
}
//[l,r]
ll get(int l, int r) {
	return query(l, r+1, 0, N, 0);
}
ll oneget(int i) {
	return get(i,i);
}
//endsegtree

vector<pair<ll,ll>>R[101010];
int main() {
	ll n, m, a;
	cin >> n >> m >> a;
	
	rep(i, 0, m) {
		ll l, r, p;
		cin >> l >> r >> p;
		R[r].pb({ l,p });
	}

	rep(i,0,n+1)st(i, -inf);
	st(0, 0);

	for (ll r = 1; r <= n; r++) {
		fore(pa, R[r]) {
			ll l = pa.first;
			ll p = pa.second;
			
			ll ma = -inf;
			ll fl = (r == n) ? 0 : a;
			ma = max(ma,oneget(l-1)-fl+p);
			ma = max(ma,get(0,l-2)-a-fl+p);
			st(r,max(oneget(r),ma));
		}
	}
	puts(get(0, n));
	return 0;
}
0