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;
typedef long long ll;
const int N = 2e5+5;
int n;
int b[N], odd[N], ans[N];
vector<pair<int, int>> a;
void read() {
cin >> n;
for(int i = 0; i <= n; i++) {
int x; cin >> x;
a.push_back({x, i});
}
sort(a.begin(), a.end());
for(int i = 0; i < n; i++)
cin >> b[i];
sort(b, b+n);
}
void solve() {
for(int i = 0; i < n; i++) {
odd[i] = max(0, a[i+1].first - b[i]);
}
for(int i = 0; i < n; i++) {
int& mx = ans[a[i].second] = 0;
for(int j = 0; j < n; j++)
mx = max(mx, odd[j]);
odd[i] = max(0, a[i].first - b[i]);
}
int& mx = ans[a[n].second] = 0;
for(int j = 0; j < n; j++)
mx = max(mx, odd[j]);
for(int i = 0; i < n+1; i++)
cout << ans[i] << " \n"[i==n];
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
read();
solve();
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... |