이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |