結果

問題 No.1950 片道きゃっちぼーる
ユーザー ruthenruthen
提出日時 2022-05-21 00:46:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 3,408 ms
コンパイル使用メモリ 220,288 KB
実行使用メモリ 21,108 KB
最終ジャッジ日時 2023-10-20 15:20:32
合計ジャッジ時間 9,746 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 192 ms
21,104 KB
testcase_04 AC 198 ms
21,104 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 211 ms
21,104 KB
testcase_07 AC 165 ms
21,104 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 207 ms
21,104 KB
testcase_12 AC 178 ms
21,104 KB
testcase_13 AC 202 ms
21,104 KB
testcase_14 AC 221 ms
21,104 KB
testcase_15 WA -
testcase_16 AC 217 ms
21,104 KB
testcase_17 WA -
testcase_18 AC 185 ms
21,104 KB
testcase_19 WA -
testcase_20 AC 179 ms
21,104 KB
testcase_21 AC 216 ms
21,104 KB
testcase_22 AC 220 ms
21,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include "debug.hpp"
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

#include <atcoder/dsu>

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    V<ll> X(N), A(N);
    rep(i, N) cin >> X[i];
    rep(i, N) cin >> A[i];
    map<ll, int> mp;
    rep(i, N) mp[X[i]] = i;
    atcoder::dsu uf(N);
    rep(i, N) {
        if (mp.count(X[i] + A[i])) {
            uf.merge(i, mp[X[i] + A[i]]);
        }
        if (mp.count(X[i] - A[i])) {
            uf.merge(i, mp[X[i] - A[i]]);
        }
    }
    V<ll> max_ind(N, -1000000000000LL);
    rep(i, N) max_ind[uf.leader(i)] = max(max_ind[uf.leader(i)], A[i] + X[i]);
    rep(i, N) cout << max_ind[uf.leader(i)] - X[i] << '\n';
    return 0;
}
0