結果

問題 No.1950 片道きゃっちぼーる
ユーザー RVindicatioRVindicatio
提出日時 2022-05-20 22:38:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 927 bytes
コンパイル時間 3,474 ms
コンパイル使用メモリ 220,176 KB
実行使用メモリ 8,052 KB
最終ジャッジ日時 2023-10-20 13:24:35
合計ジャッジ時間 7,330 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 75 ms
7,944 KB
testcase_04 AC 74 ms
7,944 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 65 ms
7,944 KB
testcase_07 AC 71 ms
7,944 KB
testcase_08 AC 71 ms
7,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 72 ms
7,944 KB
testcase_12 AC 71 ms
7,944 KB
testcase_13 AC 72 ms
7,944 KB
testcase_14 AC 71 ms
7,944 KB
testcase_15 WA -
testcase_16 AC 70 ms
7,944 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 76 ms
7,944 KB
testcase_19 WA -
testcase_20 AC 71 ms
7,944 KB
testcase_21 AC 74 ms
7,944 KB
testcase_22 AC 73 ms
7,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
const int INF = 1e9;
const ll inf = 1LL<<60;

void solve() {
  int n; cin >> n;
  vector<ll> x(n), a(n);
  vector<ll> ans(n);
  for (int i=0; i<n; i++) cin >> x[i];
  for (int i=0; i<n; i++) {
    cin >> a[i];
    ans[i] = a[i];
  }
  for (int i=n-1; i>=0; i--) {
    int cur = lower_bound(x.begin(), x.end(), a[i] + x[i]) - x.begin();
    if (cur < n && x[cur] == a[i]+x[i]) ans[i] += ans[cur];
  }
  for (int i=0; i<n; i++) {
    int cur = lower_bound(x.begin(), x.end(), x[i] - a[i]) - x.begin();
    if (x[cur] == x[i] - a[i]) ans[i] = max(ans[i], ans[cur] - (x[i] - x[cur]));
  }
  for (int i=0; i<n; i++) {
    cout << ans[i] << '\n';
  }
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  // int t; cin >> t;
  /*while (t--)*/ solve();
}
0