結果
| 問題 |
No.1950 片道きゃっちぼーる
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-21 00:46:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 886 bytes |
| コンパイル時間 | 2,325 ms |
| コンパイル使用メモリ | 212,160 KB |
| 最終ジャッジ日時 | 2025-01-29 12:25:19 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 6 |
ソースコード
#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;
}