結果

問題 No.1826 Fruits Collecting
ユーザー kwm_tkwm_t
提出日時 2022-02-03 00:32:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 1,957 bytes
コンパイル時間 5,455 ms
コンパイル使用メモリ 280,544 KB
実行使用メモリ 25,244 KB
最終ジャッジ日時 2023-09-02 03:02:51
合計ジャッジ時間 12,213 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 89 ms
10,708 KB
testcase_06 AC 156 ms
15,804 KB
testcase_07 AC 109 ms
12,768 KB
testcase_08 AC 10 ms
4,380 KB
testcase_09 AC 158 ms
15,832 KB
testcase_10 AC 100 ms
12,504 KB
testcase_11 AC 95 ms
11,136 KB
testcase_12 AC 35 ms
6,220 KB
testcase_13 AC 17 ms
4,780 KB
testcase_14 AC 28 ms
5,708 KB
testcase_15 AC 241 ms
24,356 KB
testcase_16 AC 236 ms
24,880 KB
testcase_17 AC 240 ms
24,744 KB
testcase_18 AC 247 ms
24,856 KB
testcase_19 AC 262 ms
25,056 KB
testcase_20 AC 252 ms
24,104 KB
testcase_21 AC 244 ms
25,244 KB
testcase_22 AC 248 ms
24,656 KB
testcase_23 AC 254 ms
23,652 KB
testcase_24 AC 247 ms
25,208 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 27 ms
4,692 KB
testcase_31 AC 54 ms
6,504 KB
testcase_32 AC 56 ms
8,744 KB
testcase_33 AC 215 ms
22,980 KB
testcase_34 AC 185 ms
18,032 KB
testcase_35 AC 36 ms
6,584 KB
testcase_36 AC 202 ms
22,368 KB
testcase_37 AC 114 ms
16,836 KB
testcase_38 AC 81 ms
14,340 KB
testcase_39 AC 110 ms
16,292 KB
testcase_40 AC 143 ms
18,828 KB
testcase_41 AC 29 ms
6,108 KB
testcase_42 AC 5 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 1 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 });
	}
	sort(all(vec));
	vector<long long>memo;
	rep(i, vec.size())memo.push_back(vec[i].first.second);
	memo.push_back(0);
	//
	vector<long long>vv = memo;
	sort(all(vv));
	vv.erase(unique(all(vv)), vv.end());
	map<long long, long long>mp;
	rep(i, vv.size()) mp[vv[i]] = i;
	//
	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