#include<bits/stdc++.h>
using namespace std;
#define task "JOI20_ho_t1"
#define lb lower_bound
#define ub upper_bound
#define ALL(v) (v).begin(),(v).end()
#define zs(v) int((v).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
const ll mod=1000000007; /// 998244353
const int base=311;
const int N=2e5+5;
int n,b[N],ans[N];
pii a[N];
void biot()
{
cin>>n;
for(int i=1;i<=n+1;++i) cin>>a[i].fi, a[i].se=i;
sort(a+1,a+n+2);
for(int i=1;i<=n;++i) cin>>b[i];
sort(b+1,b+n+1);
multiset<int,greater<int>> s;
for(int i=1;i<=n;++i) s.insert(abs(a[i+1].fi-b[i]));
ans[a[1].se]=*s.begin();
for(int i=2;i<=n+1;++i)
{
s.erase(s.find(abs(a[i].fi-b[i-1])));
s.insert(abs(a[i-1].fi-b[i-1]));
ans[a[i].se]=*s.begin();
}
for(int i=1;i<=n+1;++i) cout<<ans[i]<<' ';
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
if(fopen(task".inp","r"))
{
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
biot();
}
Compilation message
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
46 | freopen(task".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
47 | freopen(task".out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |