結果

問題 No.1826 Fruits Collecting
ユーザー kwm_tkwm_t
提出日時 2022-02-03 00:02:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 1,829 bytes
コンパイル時間 5,345 ms
コンパイル使用メモリ 279,040 KB
実行使用メモリ 24,400 KB
最終ジャッジ日時 2023-09-02 03:02:06
合計ジャッジ時間 12,070 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 81 ms
10,216 KB
testcase_06 AC 141 ms
15,352 KB
testcase_07 AC 100 ms
13,308 KB
testcase_08 AC 9 ms
4,376 KB
testcase_09 AC 142 ms
14,972 KB
testcase_10 AC 95 ms
12,152 KB
testcase_11 AC 91 ms
10,744 KB
testcase_12 AC 33 ms
6,352 KB
testcase_13 AC 16 ms
4,628 KB
testcase_14 AC 26 ms
5,868 KB
testcase_15 AC 229 ms
22,952 KB
testcase_16 AC 232 ms
22,448 KB
testcase_17 AC 231 ms
22,912 KB
testcase_18 AC 225 ms
22,468 KB
testcase_19 AC 226 ms
23,776 KB
testcase_20 AC 226 ms
22,772 KB
testcase_21 AC 229 ms
24,136 KB
testcase_22 AC 226 ms
22,604 KB
testcase_23 AC 234 ms
24,400 KB
testcase_24 AC 222 ms
22,780 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 26 ms
4,896 KB
testcase_31 AC 52 ms
6,412 KB
testcase_32 AC 55 ms
8,312 KB
testcase_33 AC 188 ms
21,336 KB
testcase_34 AC 159 ms
16,896 KB
testcase_35 AC 33 ms
6,344 KB
testcase_36 AC 187 ms
21,288 KB
testcase_37 AC 111 ms
16,192 KB
testcase_38 AC 78 ms
13,020 KB
testcase_39 AC 105 ms
15,624 KB
testcase_40 AC 134 ms
17,564 KB
testcase_41 AC 26 ms
6,240 KB
testcase_42 AC 5 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 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 });
	}
	sort(all(vec));
	vector<long long>memo;
	rep(i, vec.size())memo.push_back(vec[i].first.second);
	memo.push_back(0);
	auto mp = Compless(memo);
	segtree<long long, op, e>seg(mp.size());
	seg.set(mp[0], 0);
	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