結果

問題 No.1826 Fruits Collecting
ユーザー 沙耶花沙耶花
提出日時 2022-01-28 22:43:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 305 ms / 2,000 ms
コード長 1,034 bytes
コンパイル時間 4,479 ms
コンパイル使用メモリ 271,860 KB
実行使用メモリ 15,180 KB
最終ジャッジ日時 2023-08-28 21:11:56
合計ジャッジ時間 12,849 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 3 ms
4,360 KB
testcase_02 AC 3 ms
4,356 KB
testcase_03 AC 5 ms
4,360 KB
testcase_04 AC 3 ms
4,352 KB
testcase_05 AC 122 ms
8,384 KB
testcase_06 AC 202 ms
12,376 KB
testcase_07 AC 143 ms
9,024 KB
testcase_08 AC 17 ms
4,356 KB
testcase_09 AC 197 ms
10,364 KB
testcase_10 AC 134 ms
8,972 KB
testcase_11 AC 131 ms
8,440 KB
testcase_12 AC 54 ms
5,672 KB
testcase_13 AC 26 ms
4,468 KB
testcase_14 AC 43 ms
4,896 KB
testcase_15 AC 302 ms
15,180 KB
testcase_16 AC 303 ms
14,980 KB
testcase_17 AC 305 ms
15,176 KB
testcase_18 AC 304 ms
15,004 KB
testcase_19 AC 304 ms
14,984 KB
testcase_20 AC 305 ms
15,172 KB
testcase_21 AC 305 ms
14,972 KB
testcase_22 AC 304 ms
14,980 KB
testcase_23 AC 303 ms
15,004 KB
testcase_24 AC 303 ms
15,080 KB
testcase_25 AC 2 ms
4,352 KB
testcase_26 AC 1 ms
4,352 KB
testcase_27 AC 2 ms
4,356 KB
testcase_28 AC 1 ms
4,356 KB
testcase_29 AC 2 ms
4,356 KB
testcase_30 AC 65 ms
5,896 KB
testcase_31 AC 126 ms
8,740 KB
testcase_32 AC 69 ms
5,940 KB
testcase_33 AC 227 ms
12,528 KB
testcase_34 AC 191 ms
9,716 KB
testcase_35 AC 46 ms
4,904 KB
testcase_36 AC 221 ms
12,384 KB
testcase_37 AC 138 ms
9,520 KB
testcase_38 AC 99 ms
8,216 KB
testcase_39 AC 183 ms
9,816 KB
testcase_40 AC 233 ms
10,908 KB
testcase_41 AC 51 ms
5,156 KB
testcase_42 AC 8 ms
4,356 KB
testcase_43 AC 2 ms
4,356 KB
testcase_44 AC 1 ms
4,360 KB
testcase_45 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000000000000001;

long long op(long long a,long long b){
	return max(a,b);
}

long long e(){
	return -Inf;
}

int main(){
	
	int n;
	cin>>n;
	
	vector<array<long long,3>> a(n);
	rep(i,n){
		long long t,x,v;
		cin>>t>>x>>v;
		a[i][0] = t+x;
		a[i][1] = t-x;
		a[i][2] = v;
	}
	sort(a.begin(),a.end());
	vector<long long> t;
	rep(i,n)t.push_back(a[i][1]);
	t.push_back(0);
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	
	segtree<long long,op,e> seg(t.size());
	{
		int d = distance(t.begin(),lower_bound(t.begin(),t.end(),0LL));
		seg.set(d,0);
	}
	bool f = false;
	rep(i,n){
		if(a[i][0]<0||a[i][1]<0)continue;
		int d = distance(t.begin(),lower_bound(t.begin(),t.end(),a[i][1]));
		long long v = seg.prod(0,d+1);
		v += a[i][2];
		seg.set(d,max(v,seg.get(d)));
	}
	cout<<seg.all_prod()<<endl;
	
	
	return 0;
}
0