이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+9)
#define hmod 1286031825167LL
using namespace std;
int n,a[200005],b[200005],mxr[200005],mxl[200005];
int main(){
ios::sync_with_stdio(false);
cin >> n; n++;
for (int i=1;i<=n;i++){
cin >> a[i];
}
for (int i=1;i<n;i++){
cin >> b[i];
}
sort(a+1,a+1+n); sort(b+1,b+n);
for (int i=1;i<n;i++){
mxl[i]=max(mxl[i-1],a[i]-b[i]);
}
for (int i=2;i<=n;i++){
mxr[i]=max(0,a[i]-b[i-1]);
}
for (int i=n-1;i>=1;i--){
mxr[i]=max(mxr[i+1],mxr[i]);
}
for (int i=1;i<=n;i++){
cout << max(mxl[i-1],mxr[i+1]);
if (i < n)
cout << " ";
}
cout << "\n";
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... |