#include <bits/stdc++.h>
#define int long long
#define vec vector
#define all(x) x.begin(),x.end()
#define endl " \n"
#pragma GCC optimize("O2")
using namespace std;
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.precision(0);
cout<<fixed;
int n;
cin>>n;
vec<pair<int,int>> t(n+1);
for (int i = 0; i < n+1; i++)
{
cin>>t[i].first;t[i].second=i;
}
vec<int> x(n);
vec<int> rres(n+1);
for (int i = 0; i < n; i++)
{
cin>>x[i];
}
sort(all(x));
sort(all(t));
multiset<int> res;
for (int i = 1; i < n+1; i++)
{
res.insert(-max(t[i].first-x[i-1],0LL));
}
rres[t[0].second]=-*res.begin();
for (int i = 1; i < n+1; i++)
{
auto e=res.lower_bound(-max(t[i].first-x[i-1],0LL));
res.erase(e);
res.insert(-max(t[i-1].first-x[i-1],0LL));
rres[t[i].second]=-*res.begin();
}
for (int i = 0; i < n+1; i++)
{
cout<<rres[i]<<endl[i==n];
}
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... |