This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,b[200005],an[200005];
pair<ll,ll>a[200005];
multiset<ll>st;
multiset<ll>::iterator it;
int main(){
ios::sync_with_stdio(false);
cin >> n;
for(int i=1; i<=n + 1; i++){
cin >> a[i].f;
a[i].s = i;
}
sort(a + 1 , a + n + 2);
for(int i=1; i<=n; i++){
cin >> b[i];
}
sort(b + 1 , b + n + 1);
for(int i=1; i<=n; i++){
st.insert(max(0LL , a[i + 1].f - b[i]));
}
it = st.end();
it--;
an[a[1].s] = (*it);
for(int i=2; i<=n + 1; i++){
st.erase(st.find(max(0LL , a[i].f - b[i - 1])));
st.insert(max(0LL , a[i - 1].f - b[i - 1]));
it = st.end();
it--;
an[a[i].s] = (*it);
}
for(int i=1; i<=n + 1; i++)
cout << an[i] << " ";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |