# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
566969 | Dodo | Just Long Neckties (JOI20_ho_t1) | C++14 | 111 ms | 11644 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>
#define ll long long
#define endl '\n'
#define pb push_back
using namespace std;
const ll mx=1007, INF=1e18L+5;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin>>n;
ll b[n];
vector<pair<ll,ll>>v(n+1);
for(int i=0;i<=n;i++)
{
ll x; cin>>x;
v[i]={x,i};
}
for(int i=0;i<n;i++)cin>>b[i];
sort(v.begin(),v.end());
sort(b,b+n);
ll p1[n],p2[n];
ll mx=0;
for(int i=0;i<n;i++)
{
mx=max(mx,v[i].first-b[i]);
p1[i]=mx;
}
mx=0;
for(int i=n;i>=1;i--)
{
mx=max(mx,v[i].first-b[i-1]);
p2[i-1]=mx;
}
ll f[n+1];
for(int i=0;i<=n;i++)
{
ll x,y,ans=0;
if(i-1>=0)ans=max(ans,p1[i-1]);
if(i!=n)ans=max(ans,p2[i]);
f[v[i].second]=ans;
}
for(int i=0;i<=n;i++)cout<<f[i]<<' ';
return 0;
}
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... |