結果
| 問題 |
No.1826 Fruits Collecting
|
| コンテスト | |
| ユーザー |
たたき@競プロ
|
| 提出日時 | 2023-08-18 03:55:38 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,036 bytes |
| コンパイル時間 | 5,783 ms |
| コンパイル使用メモリ | 321,096 KB |
| 実行使用メモリ | 15,536 KB |
| 最終ジャッジ日時 | 2024-11-27 06:30:39 |
| 合計ジャッジ時間 | 15,427 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 18 WA * 25 |
ソースコード
#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;
}
たたき@競プロ