이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
ll n, a[(int)2e5+5], b[(int)2e5+5], c1[(int)2e5+5], c2[(int)2e5+5];
pair <ll, ll> c[(int)2e5+5];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
for(int i = 1; i <= n+1; i++) cin>>a[i];
for(int i = 1; i <= n; i++) cin>>b[i];
sort(a+1, a+n+2); sort(b+1, b+n+1);
// for(int i = 1; i <= n+1; i++) cout<<a[i]<<" ";
//
// cout<<endl;
//
// for(int i = 1; i <= n; i++) cout<<b[i]<<" ";
//
// cout<<endl;
c1[0] = -1e18; c2[n+1] = -1e18;
for(int i = 1; i <= n; i++){
c[i].f = max(0ll, a[i]-b[i]);
c[i].s = max(0ll, a[i+1]-b[i]);
c1[i] = max(c1[i-1], c[i].f);
}
for(int i = n; i >= 1; i--){
c2[i] = max(c2[i+1], c[i].s);
}
// for(int i = 1; i <= n; i++) cout<<c[i].s<<" ";
for(int i = 1; i <= n+1; i++){
cout<<max(c1[i-1], c2[i])<<" ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |