이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
const int MAX=2e5+10, MAXV=2e9+10;
int n, b[MAX], maxil[MAX], maxip[MAX], wynik[MAX];
pair<int,int>a[MAX];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin>>n;
for(int i=1; i<=n+1; i++){
cin>>a[i].fi;
a[i].se=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; i++)
maxil[i]=max(maxil[i-1], max(0, a[i].fi-b[i]));
for(int i=n+1; i>=2; i--)
maxip[i]=max(maxip[i+1], max(0, a[i].fi-b[i-1]));
for(int i=1; i<=n+1; i++)
wynik[a[i].se]=max(maxil[i-1], maxip[i+1]);
for(int i=1; i<=n+1; i++)
cout<<wynik[i]<<" ";
cout<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |