# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
365216 | jazzup | Just Long Neckties (JOI20_ho_t1) | C++17 | 181 ms | 6276 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<cstdio>
#include<algorithm>
using namespace std;
int a[200010],aa[200010],b[200010],dp1[200010],dp2[200010];
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<=n;i++){
scanf("%d",&aa[i]);
a[i]=aa[i];
}
sort(a,a+n+1);
for(int i=0;i<n;i++){
scanf("%d",&b[i]);
}
sort(b,b+n);
dp1[0]=max(a[0]-b[0],0);
for(int i=1;i<n;i++){
dp1[i]=max(dp1[i-1],max(a[i]-b[i],0));
}
dp2[n-1]=max(a[n]-b[n-1],0);
for(int i=n-2;i>=0;i--){
dp2[i]=max(dp2[i+1],max(a[i+1]-b[i],0));
}
for(int i=0;i<=n;i++){
int *p=lower_bound(a,a+n+1,aa[i]);
int x=p-a;
printf("%d ",max(dp1[x-1],dp2[x]));
}
// for(int i=0;i<n;i++){
// printf("%d ",dp1[i]);
// }
// printf("\n");
// for(int i=0;i<n;i++){
// printf("%d ",dp2[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... |