# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
929095 | haru09 | Just Long Neckties (JOI20_ho_t1) | C++17 | 77 ms | 10832 KiB |
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>
using namespace std;
#define ll long long
#define fi first
#define se second
#define task "code"
const int ar=2e5+5;
const ll mod=1e9+7;
int n;
pair<int,int> a[ar];
int b[ar];
int pre[ar];
int suf[ar];
int ans[ar];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if (fopen(task".inp","r"))
{
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
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++) pre[i]=max({0,pre[i-1],a[i].fi-b[i]});
for (int i=n;i>=1;i--) suf[i]=max({0,suf[i+1],a[i+1].fi-b[i]});
for (int i=1;i<=n+1;i++) ans[a[i].se]=max(pre[i-1],suf[i]);
for (int i=1;i<=n+1;i++) cout<<ans[i]<<' ';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |