#include<bits/stdc++.h>
using namespace std;
#define xx first
#define yy second
//3 4 6 7
//2 4 6
//3 4 7
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
vector<pair<int,int>> a(n+1), b(n);
for(int i=0;i<n+1;++i) {
cin>>a[i].xx;
a[i].yy=i;
}
for(int i=0;i<n;++i) {
cin>>b[i].xx;
b[i].yy=i;
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector<int> pre(n+1);
vector<int> suf(n+1);
for(int i=0;i<n;++i) {
pre[i]=max(0, a[i+1].xx-b[i].xx);
suf[i+1]=max(0, a[i].xx-b[i].xx);
}
for(int i=n-1;i>=0;i--) pre[i]=max(pre[i], pre[i+1]);
for(int i=1;i<n+1;i++) suf[i]=max(suf[i], suf[i-1]);
//~ for(auto i:pre) {
//~ cerr<<i<<" ";
//~ }cerr<<"\n";
//~ for(auto i:suf) {
//~ cerr<<i<<" ";
//~ }cerr<<"\n";
vector<int> ans=pre;
for(int i=n;i>=0;i--) ans[i]=max(ans[i], suf[i]);
for(int i=0;i<n+1;++i) cout<<ans[a[i].yy]<<" ";
cout<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |