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;
const int N = 1e6 + 66;
pair<int,int> a[N];
int ans[N], b[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = 1 ; i <= n + 1 ; ++ i) {
cin >> a[i].first; a[i].second = i;
}
for (int i = 1 ; i <= n ; ++ i) cin >> b[i];
sort(a + 1, a + 2 + n); sort(b + 1, b + 1 + n);
multiset<int> s = {0};
for (int i = 1 ; i <= n ; ++ i) {
s.insert(a[i + 1].first - b[i]);
}
for (int i = 1 ; i - 1 <= n ; ++ i) {
ans[a[i].second] =*s.rbegin();
if (i <= n) {
s.erase(s.find(a[i + 1].first - b[i]));
s.insert(a[i].first - b[i]);
}
}
for (int i = 1 ; i <= n + 1 ; ++ i) cout << ans[i] << " ";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |