#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastIO cin.tie(0); ios::sync_with_stdio(false)
int main() {
fastIO;
int n; cin >> n;
vector<pair<int, int>> ties(n+1);
vector<int> people(n);
multiset<int> times;
for(int i = 0; i < n+1; i++) {
cin >> ties[i].first;
ties[i].second = i;
}
for(int i = 0; i < n; i++) cin >> people[i];
sort(ties.begin(), ties.end());
sort(people.begin(), people.end());
vector<int> ans(n+1, 0);
for(int i = 0; i < n; i++) {
times.emplace(ties[i+1].first - people[i]);
}
ans[ties[0].second] = max(0, *times.rbegin());
for(int i = 0; i < n; i++) {
times.extract(ties[i+1].first - people[i]);
times.emplace(ties[i].first - people[i]);
ans[ties[i+1].second] = max(0, *times.rbegin());
}
for(auto i : ans) cout << 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... |