暴力也行,退火也行,不是很明白为啥还要用半平面交……
总之就是把原来的所有限制看成一堆半平面//minamoto#include#define fp(i,a,b) for(register int i=a,I=b+1;i I;--i)template 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 =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\n",ans);return 0;}