結果

問題 No.1826 Fruits Collecting
ユーザー kwm_tkwm_t
提出日時 2022-02-03 00:36:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 1,918 bytes
コンパイル時間 4,808 ms
コンパイル使用メモリ 279,764 KB
実行使用メモリ 24,188 KB
最終ジャッジ日時 2023-09-02 03:03:05
合計ジャッジ時間 12,149 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 90 ms
10,068 KB
testcase_06 AC 161 ms
14,976 KB
testcase_07 AC 110 ms
13,292 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 163 ms
15,148 KB
testcase_10 AC 100 ms
12,000 KB
testcase_11 AC 95 ms
10,628 KB
testcase_12 AC 37 ms
6,204 KB
testcase_13 AC 17 ms
4,580 KB
testcase_14 AC 28 ms
5,784 KB
testcase_15 AC 263 ms
22,924 KB
testcase_16 AC 268 ms
24,188 KB
testcase_17 AC 270 ms
23,936 KB
testcase_18 AC 272 ms
23,172 KB
testcase_19 AC 270 ms
23,060 KB
testcase_20 AC 249 ms
23,780 KB
testcase_21 AC 264 ms
22,996 KB
testcase_22 AC 259 ms
22,828 KB
testcase_23 AC 267 ms
23,484 KB
testcase_24 AC 266 ms
22,332 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 27 ms
4,776 KB
testcase_31 AC 54 ms
6,260 KB
testcase_32 AC 57 ms
8,316 KB
testcase_33 AC 219 ms
21,480 KB
testcase_34 AC 185 ms
16,920 KB
testcase_35 AC 35 ms
6,200 KB
testcase_36 AC 224 ms
21,276 KB
testcase_37 AC 113 ms
16,104 KB
testcase_38 AC 82 ms
12,988 KB
testcase_39 AC 103 ms
13,900 KB
testcase_40 AC 133 ms
16,716 KB
testcase_41 AC 27 ms
5,788 KB
testcase_42 AC 5 ms
4,384 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<long long,long long>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
long long op(long long a, long long b) { return max(a, b); }
long long e() { return -LINF; }
map<long long, long long> Compless(const vector<long long> &v) {
	vector<long long>vv = v;
	sort(all(vv));
	vv.erase(unique(all(vv)), vv.end());
	map<long long, long long>mp;
	rep(i, vv.size()) mp[vv[i]] = i;
	return mp;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	vector<pair<P, long long>>vec;
	vec.push_back({ {0 - 0,0 + 0},0 });
	rep(i, n) {
		int t, x, v; cin >> t >> x >> v;
		if (t - x >= 0)vec.push_back({ {t - x,t + x},v });
	}
	//
	vector<long long>tmp(vec.size());
	rep(i, vec.size())tmp[i] = vec[i].first.second;
	sort(all(tmp));
	tmp.erase(unique(all(tmp)), tmp.end());
	map<long long, long long>mp;
	rep(i, tmp.size()) mp[tmp[i]] = i;
	//
	segtree<long long, op, e>seg(mp.size());
	seg.set(mp[0], 0);
	sort(all(vec));
	rep(i, vec.size()) {
		int idx = mp[vec[i].first.second];
		long long get = seg.prod(0, idx + 1);
		if (-LINF == get)continue;
		seg.set(idx, get + vec[i].second);
	}
	cout << seg.all_prod() << endl;
	return 0;
}
0