This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#define ll long long
#define eps 1e-8
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
// change if necessary
#define MAXN 200000
using namespace std;
int n;
vector<pair<ll, int>> a;
vector<ll> b;
multiset<ll> cur;
int ans[MAXN];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n + 1; i++) {
ll x; cin >> x;
a.push_back({x, i});
}
for (int i = 0; i < n; i++) {
ll x; cin >> x;
b.push_back(x);
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for (int i = 0; i < n; i++) {
cur.insert(abs(a[i + 1].first - b[i]));
}
ans[a[0].second] = *cur.rbegin();
for (int i = 1; i <= n; i++) {
cur.erase(cur.find(abs(a[i].first - b[i - 1])));
cur.insert(abs(a[i - 1].first - b[i - 1]));
ans[a[i].second] = *cur.rbegin();
}
for (int i = 0; i <= n; i++) {
cout << ans[i] << ' ';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |