暴力也行,退火也行,不是很明白为啥还要用半平面交……
总之就是把原来的所有限制看成一堆半平面
根据黄学长的博客塔肯定建在转折处最优
//minamoto
#include<bits/stdc++.h>
#define fp(i,a,b) for(register int i=a,I=b+1;i<I;++i)
#define fd(i,a,b) for(register int i=a,I=b-1;i>I;--i)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
#define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<21],*p1=buf,*p2=buf;
int read(){
int res,f=1;char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
return res*f;
}
const int N=1005;
struct node{double x,y;}p[N],a[N];
struct L{node a,b;double sl;}l[N],q[N];
int n,cnt,top,tot;double ans=1e60;
inline node operator -(node a,node b){return {a.x-b.x,a.y-b.y};}
inline double operator *(node a,node b){return a.x*b.y-a.y*b.x;}
inline bool operator <(L a,L b){
if(a.sl!=b.sl)return a.sl<b.sl;
return (a.b-a.a)*(b.b-a.a)<0;
}
node inter(L a,L b){
double k1,k2,t;
k1=(b.b-a.a)*(a.b-a.a);
k2=(a.b-a.a)*(b.a-a.a);
t=k1/(k1+k2);
return {b.b.x+(b.a.x-b.b.x)*t,b.b.y+(b.a.y-b.b.y)*t};
}
inline bool jd(L a,L b,L t){node p=inter(a,b);return (t.b-t.a)*(p-t.a)<0;}
void hpi(){
int h=1,t=0;tot=0;
fp(i,1,cnt)if(l[i].sl!=l[i-1].sl)l[++tot]=l[i];
cnt=tot,q[++t]=l[1],q[++t]=l[2];
fp(i,3,cnt){
while(h<t&&jd(q[t-1],q[t],l[i]))--t;
while(h<t&&jd(q[h+1],q[h],l[i]))++h;
q[++t]=l[i];
}
while(h<t&&jd(q[t-1],q[t],q[h]))--t;
while(h<t&&jd(q[h+1],q[h],q[t]))++h;
tot=0;fp(i,h,t-1)a[++tot]=inter(q[i],q[i+1]);
}
void init(){
p[0]={p[1].x,100001},p[n+1]={p[n].x,100001};
fp(i,1,n){
l[++cnt].a=p[i-1],l[cnt].b=p[i];
l[++cnt].a=p[i],l[cnt].b=p[i+1];
}
fp(i,1,cnt)l[i].sl=atan2(l[i].b.y-l[i].a.y,l[i].b.x-l[i].a.x);
sort(l+1,l+1+cnt);
}
void getans(){
fp(k,1,tot)fp(i,1,n-1)if(a[k].x>=p[i].x&&a[k].x<=p[i+1].x){
node t;t.x=a[k].x,t.y=-1;
cmin(ans,a[k].y-inter(L{p[i],p[i+1]},L{t,a[k]}).y);
}
fp(k,1,n)fp(i,1,tot-1)if(p[k].x>=a[i].x&&p[k].x<=a[i+1].x){
node t;t.x=p[k].x,t.y=-1;
cmin(ans,inter(L{a[i],a[i+1]},L{t,p[k]}).y-p[k].y);
}
}
int main(){
// freopen("testdata.in","r",stdin);
n=read();fp(i,1,n)p[i].x=read();fp(i,1,n)p[i].y=read();
init(),hpi(),getans();
printf("%.3lf
",ans);return 0;
}