이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;++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]));
}
ans[ind[n]] = -(*c.begin());
for(auto c:ans)
cout << c << ' ';
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... |