#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
#define int long long
using namespace std;
signed main(){
AquA;
int n;
cin >> n;
vector<pair<int,int> > v(n+1);
vector<int> b(n);
for(int i=0;i<=n;i++){
cin >> v[i].fs;
v[i].sc=i;
}
for(int i=0;i<n;i++){
cin >> b[i];
}
sort(b.begin(),b.end());
sort(v.begin(),v.end());
vector<int> ans(n+1);
multiset<int,greater<int> > m;
for(int i=0;i<n;i++){
m.insert(abs(v[i+1].fs-b[i]));
}
for(int i=0;i<=n;i++){
ans[v[i].sc]=*m.begin();
if(i!=n){
m.erase(m.find(abs(v[i+1].fs-b[i])));
m.insert(abs(v[i].fs-b[i]));
}
}
for(int i=0;i<=n;i++){
cout << ans[i] << " ";
}
cout << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |