結果

問題 No.1950 片道きゃっちぼーる
ユーザー asaringoasaringo
提出日時 2022-05-21 00:03:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,509 bytes
コンパイル時間 1,894 ms
コンパイル使用メモリ 205,564 KB
実行使用メモリ 176,728 KB
最終ジャッジ日時 2023-10-20 14:57:19
合計ジャッジ時間 23,287 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1,217 ms
176,556 KB
testcase_04 AC 985 ms
164,252 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1,165 ms
176,728 KB
testcase_07 AC 581 ms
164,252 KB
testcase_08 AC 674 ms
164,056 KB
testcase_09 WA -
testcase_10 AC 778 ms
164,056 KB
testcase_11 AC 716 ms
164,056 KB
testcase_12 AC 694 ms
164,056 KB
testcase_13 AC 1,248 ms
164,056 KB
testcase_14 AC 1,151 ms
164,056 KB
testcase_15 WA -
testcase_16 AC 1,202 ms
170,460 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 837 ms
164,056 KB
testcase_19 WA -
testcase_20 AC 690 ms
164,056 KB
testcase_21 AC 997 ms
164,056 KB
testcase_22 AC 1,005 ms
164,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
#define fast_input_output ios::sync_with_stdio(false); cin.tie(nullptr);
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define endl "\n"

int n ;
vector<ll> X , A ;
ll dp[202020][101] ;

ll rec1(int v , int k){
    if(dp[v][k] != -1) return dp[v][k] ;

    ll res = max(X[v]+A[v],dp[v][k-1]) ;
    auto it = lower_bound(X.begin(),X.end(),X[v]+A[v]) ;
    if(*it == X[v]+A[v]){
        int u = it - X.begin() ;
        chmax(res,rec1(u,k)) ;
    }
    return dp[v][k] = res ;
}

ll rec2(int v , int k){
    if(dp[v][k] != -1) return dp[v][k] ;

    ll res = max(dp[v][k-1],dp[v][k-2]) ;
    auto jt = lower_bound(X.begin(),X.end(),X[v]-A[v]) ;
    if(*jt == X[v]-A[v]){
        int u = jt - X.begin() ;
        chmax(res,rec2(u,k)) ;
    }
    return dp[v][k] = res ;
}

int main(){
    fast_input_output
    cin >> n ;
    X.resize(n+1) ;
    A.resize(n+1) ;
    rep(i,n) cin >> X[i] ;
    rep(i,n) cin >> A[i] ;
    X[n] = 1e16 ;
    rep(i,n) rep(j,70) dp[i][j] = -1 ;
    for(int i = 1 ; i <= 60 ; i+=2){
        rep(j,n) {
            rec1(j,i) ;
            rec2(j,i+1) ;
        }
    }
    rep(i,n) cout << dp[i][60] - X[i] << endl ;
}
0