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 <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> bool cmin(T &i, T j) { return i > j ? i=j,true:false; }
template<class T> bool cmax(T &i, T j) { return i < j ? i=j,true:false; }
constexpr int nax = 200200;
pair<int,int> a[nax];
int b[nax];
int n;
ll ans[nax];
int main() {
cin >> n;
for (int i=0;i<=n;i++) {
cin >> a[i].first;
a[i].second = i;
}
for (int i=0;i<n;i++) {
cin >> b[i];
}
sort(a,a+n+1);
sort(b,b+n);
multiset<ll> res;
for (int i=0;i<n;i++) {
res.insert(max(0,a[i+1].first-b[i]));
}
ans[a[0].second] = *res.rbegin();
for (int i=1;i<=n;i++) {
res.erase(res.find(max(0,a[i].first-b[i-1])));
res.insert(max(0,a[i-1].first-b[i-1]));
ans[a[i].second] = *res.rbegin();
}
for (int i=0;i<=n;i++) {
cout << ans[i] << " ";
}
cout << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |