結果

問題 No.1826 Fruits Collecting
ユーザー IKyopro
提出日時 2020-11-01 16:43:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 942 bytes
コンパイル時間 1,862 ms
コンパイル使用メモリ 197,264 KB
最終ジャッジ日時 2025-01-15 18:46:37
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 TLE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

int main(){
    int N;
    cin >> N;
    vec<int> X(N+1),T(N+1),V(N+1);
    for(int i=1;i<=N;i++){
        cin >> T[i] >> X[i] >> V[i];
    }
    N++;
    ll inf = 1e18;
    vec<ll> dp(N,-inf);
    auto dfs = [&](auto&& self,int c)->ll{
        if(dp[c]!=-inf) return dp[c];
        dp[c] = V[c];
        for(int i=0;i<N;i++) if(T[c]<T[i]){
            int dt = T[i]-T[c];
            if(X[c]+dt>=X[i] && X[c]-dt<=X[i]) chmax(dp[c],V[c]+self(self,i));
        }
        return dp[c];
    };
    cout << dfs(dfs,0) << "\n";
}
0