結果
問題 |
No.1950 片道きゃっちぼーる
|
ユーザー |
![]() |
提出日時 | 2022-05-20 22:38:07 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 927 bytes |
コンパイル時間 | 10,414 ms |
コンパイル使用メモリ | 275,224 KB |
最終ジャッジ日時 | 2025-01-29 11:04:28 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 4 |
ソースコード
#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(); }