#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
ll ans[n+1];
int ind[n+2];
ll a[n+2],b[n+1];
multiset<ll> c;
for(int i = 0;i < n+1;++i)
{
cin >> a[i];
ind[i] = i;
}
sort(ind,ind + n + 1,[&](int x,int y){return a[x] < a[y];});
for(int i = 0;i < n;++i)
cin >> b[i];
sort(b,b+n);
for(int i = 0;i < n;++i)
{
c.insert(-max(0ll,a[ind[i+1]] - b[i]));
}
for(int i =0;i < n+1;++i)
{
ans[ind[i]] = -(*c.begin());
c.erase(c.find(-max(0ll,a[ind[i+1]] - b[i])));
c.insert(-max(0ll,a[ind[i]] - b[i]));
}
for(auto c:ans)
cout << c << ' ';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |