#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
pair<int, int> arr[n+1];
int ties[n];
for(int i=0; i<=n; i++){
cin >> arr[i].first;
arr[i].second = i;
}
for(int i=0; i<n; i++){
cin >> ties[i];
}
sort(arr, arr+n+1);
sort(ties, ties+n);
int ans[n+1];
multiset<int, greater<int>> st;
for(int i=1; i<=n; i++){
st.insert(abs(ties[i-1]-arr[i].first));
ans[0]=*st.begin();
}
for(int taken = 1; taken<=n; taken++){
st.erase(st.find(abs(arr[taken].first-ties[taken-1])));
st.insert(abs(arr[taken-1].first-ties[taken-1]));
ans[taken]=*st.begin();
}
int finans[n+1];
for(int i=0; i<=n; i++){
finans[arr[i].second]=ans[i];
}
for(int i=0; i<=n; i++){
cout << finans[i] << ' ';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |