# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
315336 | Dymo | Just Long Neckties (JOI20_ho_t1) | C++14 | 109 ms | 15608 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 pb push_back
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
const ll maxn=5e5+50;
const ll mod =1e9+7;
const ll base=113;
pll a[maxn];
ll l[maxn];
ll r[maxn];
ll b[maxn];
ll ans[maxn];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen("GIDDY.inp", "r"))
{
freopen("GIDDY.inp", "r", stdin);
freopen("GIDDY.out", "w", stdout) ;
}
ll n;
cin>>n ;
for (int i=1;i<=n+1;i++)
{
cin>>a[i].ff;
a[i].ss=i;
}
sort(a+1,a+n+2);
/* for (int i=1;i<=n+1;i++)
{
cout <<a[i].ff<<" "<<a[i].ss<<endl;
}*/
for (int i=1;i<=n;i++)
{
cin>>b[i];
}
sort(b+1,b+n+1);
for (int i=1;i<=n;i++)
{
l[i]=max(l[i-1],max(0ll,a[i].ff-b[i]));
}
for (int i=n;i>=1;i--)
{
r[i]=max(r[i+1],max(0ll,a[i+1].ff-b[i]));
}
for (int i=1;i<=n+1;i++)
{
ans[a[i].ss]=max(l[i-1],r[i]);
/*
// cout <<l[i-1]<<" "<<r[i+1]<<" "<<i<<endl;
}*/
}
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... |