# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
359882 | shahriarkhan | Just Long Neckties (JOI20_ho_t1) | C++14 | 165 ms | 11868 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 ;
int main()
{
int n ;
scanf("%d",&n) ;
int a[n+1] , b[n+1] , pref[n+2] = {0} , suf[n+2] = {0} , ans[n+2] = {0} ;
vector<pair<int,int> > v ;
v.push_back({0,0}) ;
for(int i = 1 ; i <= (n+1) ; ++i)
{
scanf("%d",&a[i]) ;
v.push_back({a[i],i}) ;
}
for(int i = 1 ; i <= n ; ++i) scanf("%d",&b[i]) ;
sort(v.begin()+1,v.end()) ;
sort(b+1,b+n+1) ;
for(int i = 1 ; i <= n ; ++i)
{
pref[i] = max(pref[i-1],v[i].first-b[i]) ;
}
for(int i = n ; i >= 1 ; --i)
{
suf[i] = max(suf[i+1],v[i+1].first-b[i]) ;
}
for(int i = 1 ; i <= (n+1) ; ++i)
{
ans[v[i].second] = max(pref[i-1],suf[i]) ;
}
for(int i = 1 ; i <= (n+1) ; ++i) printf("%d ",ans[i]) ;
printf("\n") ;
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... |