이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ARRS ((ll)(4e5+100))
#define fr first
#define sc second
#define pb push_back
#define MX ((ll)(1e9+100))
#define MAX ((ll)(1e18+100))
ll n;
pair<ll,ll> a[ARRS];
ll b[ARRS];
ll ans[ARRS];
int main(){
cin>>n;
for(int i=0; i<=n; i++){
cin>>a[i].fr;
a[i].sc=i;
}
for(int i=0; i<n; i++){
cin>>b[i];
}
sort(a,a+n+1);
sort(b,b+n);
multiset<ll> st;
for(int i=0; i<n; i++)
st.insert(a[i].fr-b[i]);
for(int i=n; i>=0; i--){
ans[a[i].sc]=*(--st.end());
if(i)
st.erase(st.find(a[i-1].fr-b[i-1]));
st.insert(a[i].fr-b[i-1]);
}
for(int i=0; i<=n; i++){
cout<<ans[i]<<" ";
}
cout<<endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |