結果

問題 No.1826 Fruits Collecting
ユーザー kwm_tkwm_t
提出日時 2022-02-03 00:38:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 1,919 bytes
コンパイル時間 4,839 ms
コンパイル使用メモリ 277,080 KB
実行使用メモリ 14,716 KB
最終ジャッジ日時 2023-09-02 03:03:16
合計ジャッジ時間 10,308 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 56 ms
6,480 KB
testcase_06 AC 93 ms
9,192 KB
testcase_07 AC 65 ms
8,068 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 90 ms
9,372 KB
testcase_10 AC 64 ms
7,748 KB
testcase_11 AC 59 ms
6,796 KB
testcase_12 AC 24 ms
4,492 KB
testcase_13 AC 13 ms
4,376 KB
testcase_14 AC 20 ms
4,516 KB
testcase_15 AC 146 ms
13,372 KB
testcase_16 AC 144 ms
14,716 KB
testcase_17 AC 144 ms
14,064 KB
testcase_18 AC 144 ms
13,576 KB
testcase_19 AC 147 ms
13,956 KB
testcase_20 AC 142 ms
14,588 KB
testcase_21 AC 142 ms
14,100 KB
testcase_22 AC 141 ms
14,328 KB
testcase_23 AC 140 ms
14,268 KB
testcase_24 AC 141 ms
14,544 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 22 ms
4,376 KB
testcase_31 AC 42 ms
4,548 KB
testcase_32 AC 35 ms
5,936 KB
testcase_33 AC 118 ms
13,936 KB
testcase_34 AC 98 ms
9,560 KB
testcase_35 AC 22 ms
4,828 KB
testcase_36 AC 117 ms
13,136 KB
testcase_37 AC 70 ms
9,676 KB
testcase_38 AC 52 ms
8,148 KB
testcase_39 AC 73 ms
9,932 KB
testcase_40 AC 89 ms
11,888 KB
testcase_41 AC 21 ms
4,864 KB
testcase_42 AC 4 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 1 ms
4,380 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());
	//
	segtree<long long, op, e>seg(tmp.size());
	seg.set(lower_bound(all(tmp), 0) - tmp.begin(), 0);
	sort(all(vec));
	rep(i, vec.size()) {
		int idx = lower_bound(all(tmp), vec[i].first.second) - tmp.begin();
		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