結果
| 問題 |
No.1826 Fruits Collecting
|
| コンテスト | |
| ユーザー |
たたき@競プロ
|
| 提出日時 | 2023-08-18 04:02:19 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 308 ms / 2,000 ms |
| コード長 | 1,026 bytes |
| コンパイル時間 | 5,226 ms |
| コンパイル使用メモリ | 321,100 KB |
| 実行使用メモリ | 15,388 KB |
| 最終ジャッジ日時 | 2024-11-27 06:37:22 |
| 合計ジャッジ時間 | 13,306 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#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)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;
}
たたき@競プロ